### Materials for replicating “Choosing Women: Elite Preferences and women's underrepresentation in the candidate selection process”
### Authors: Malu A. C. Gatto & Marco Radojevic 
### Date: 26/08/2024

### This script prepares the raw conjoint data for analysis. It requires the file "CandidateFinal.csv". 


##Load Packages

library("tidyr")
library("stringr")
library("reshape2")
library("cjoint")
library("plyr")
library("car")
library("stargazer")
library("cregg")
library("ggplot2")
library("scales")
library("ggthemes")
library("gridExtra")
library("ggpubr")
library("cowplot")
library("multiwayvcov")
library("lmtest")
library("MASS")
library ("cowplot")
library("grid")

##Set your working directory (set your own path here)
setwd("/Users/malugatto/Library/CloudStorage/GoogleDrive-maluaberceb@gmail.com/My Drive/Marco and Malu/Gatekeepers")

##Load data
load("data4.RData")


#Estimate marginal means
f1 <- Choice ~  Conjoint.Age + Conjoint.MIP + Conjoint.Experience + Conjoint.Education + Conjoint.Ideology + Conjoint.Gender
mm.all <- mm(data4, f1, id = ~ID,  alpha = 0.05)


####################################
# Produce figures in the main text #
####################################

### FIGURE 1

data4$Share10 <- ifelse(data4$Conjoint.Share == "10 Prozent Frauen, 90 Prozent MÃ¤nner", 1,0)
data4$Share20 <- ifelse(data4$Conjoint.Share == "20 Prozent Frauen, 80 Prozent MÃ¤nner", 1,0)
data4$Share30 <- ifelse(data4$Conjoint.Share == "30 Prozent Frauen,  70 Prozent MÃ¤nner", 1,0)
data4$Share40 <- ifelse(data4$Conjoint.Share == "40 Prozent Frauen, 60 Prozent MÃ¤nner", 1,0)
data4$Share50 <- ifelse(data4$Conjoint.Share == "50 Prozent Frauen, 50 Prozent MÃ¤nner", 1,0)

mm.10 <- mm(data4[data4$Share10 == 1,], f1, id = ~ID,  alpha = 0.05)
mm.20 <- mm(data4[data4$Share20 == 1,], f1, id = ~ID,  alpha = 0.05)
mm.30 <- mm(data4[data4$Share30 == 1,], f1, id = ~ID,  alpha = 0.05)
mm.40 <- mm(data4[data4$Share40 == 1,], f1, id = ~ID,  alpha = 0.05)
mm.50 <- mm(data4[data4$Share50 == 1,], f1, id = ~ID,  alpha = 0.05)


ggData <- data.frame(rbind(cbind(fold = "10% Women, 90% Men", mm.10),
                           cbind(fold = "20% Women, 80% Men", mm.20),
                           cbind(fold = "30% Women, 70% Men", mm.30),
                           cbind(fold = "40% Women, 60% Men", mm.40),
                           cbind(fold = "50% Women, 50% Men", mm.50)))


ggData$level <- factor(as.character(ggData$level), 
                       levels = rev(c("Under 30","30-39","40-49", "50-59", "60 and Older",
                                      "Taxation", "Energy Policy", "Gender Equality", "Immigration",
                                      "Law & Order", "Welfare",
                                      "Local Council", "State Legislature", "National Legislature",
                                      "High School", "University Degree", "PhD", "Same Position",
                                      "More Leftwing", "More Rightwing",
                                      "Man", "Woman"
                       )))


ggData$stat_label <- NA
ggData$stat_label[ggData$statistic == "mm"] <- "Pooled Sample"

ggData$hline <- NA
ggData$hline[ggData$statistic == "mm"] <- 0.5


ggData$feature2 <- NA
ggData$feature2[ggData$feature == "Conjoint.Age"] = "Age"
ggData$feature2[ggData$feature == "Conjoint.Gender"] = "Aspirant Gender"
ggData$feature2[ggData$feature == "Conjoint.Experience"] = "Experience"
ggData$feature2[ggData$feature == "Conjoint.MIP"] = "Issue"
ggData$feature2[ggData$feature == "Conjoint.Education"] = "Education"
ggData$feature2[ggData$feature == "Conjoint.Ideology"] = "Ideology"


ggData$feature2 <- as.factor(ggData$feature2)
ggData$feature2 <- (factor(ggData$feature2, levels = c("Aspirant Gender")))

ggData[is.na(ggData$lower),"lower"] <- 0
ggData[is.na(ggData$upper),"upper"] <- 0

p = ggplot(ggData[ggData$feature %in% c("Conjoint.Gender"),])
p = p + geom_pointrange(aes(x = as.factor(level), y = estimate, ymin = lower, ymax = upper), )
p = p + geom_hline(aes(yintercept = hline), linetype = 2)
p = p + facet_grid(fold~ feature2, scales = "free_y") + xlab("") + ylab("Marginal Means")
p = p + coord_flip() + theme(axis.text = element_text(size = rel(0.7)),
                             axis.ticks = element_line(colour = "black"),
                             legend.key = element_rect(fill = "white"),
                             plot.margin = unit(c(0, 0, 0, 0), "cm"),
                             panel.background = element_rect(fill = "white", colour = NA),
                             panel.border = element_rect(fill = NA, colour = "grey50"),
                             panel.grid.major = element_line(colour = "grey90", size = 0.2),
                             panel.grid.minor = element_line(colour = "grey98", size = 0.5),
                             strip.background = element_rect(fill = "white", colour = "grey50"),
                             strip.text.x = element_text(size = 12, colour = "black", face = "bold"),
                             strip.text.y = element_text(size = 5, colour = "black", face = "bold"))
p



### FIGURE 2

data4$Share10 <- ifelse(data4$Conjoint.Share == "10 Prozent Frauen, 90 Prozent MÃ¤nner", 1,0)
data4$Share20 <- ifelse(data4$Conjoint.Share == "20 Prozent Frauen, 80 Prozent MÃ¤nner", 1,0)
data4$Share30 <- ifelse(data4$Conjoint.Share == "30 Prozent Frauen,  70 Prozent MÃ¤nner", 1,0)
data4$Share40 <- ifelse(data4$Conjoint.Share == "40 Prozent Frauen, 60 Prozent MÃ¤nner", 1,0)
data4$Share50 <- ifelse(data4$Conjoint.Share == "50 Prozent Frauen, 50 Prozent MÃ¤nner", 1,0)

mm.10R <- mm(data4[data4$Share10 == 1 & data4$Rough_Ideology == "Right Wing",], f1, id = ~ID,  alpha = 0.05)
mm.10C <- mm(data4[data4$Share10 == 1 & data4$Rough_Ideology == "Center",], f1, id = ~ID,  alpha = 0.05)
mm.10L <- mm(data4[data4$Share10 == 1 & data4$Rough_Ideology == "Left Wing",], f1, id = ~ID,  alpha = 0.05)


mm.20R <- mm(data4[data4$Share20 == 1 & data4$Rough_Ideology == "Right Wing",], f1, id = ~ID,  alpha = 0.05)
mm.20C <- mm(data4[data4$Share20 == 1 & data4$Rough_Ideology == "Center",], f1, id = ~ID,  alpha = 0.05)
mm.20L <- mm(data4[data4$Share20 == 1 & data4$Rough_Ideology == "Left Wing",], f1, id = ~ID,  alpha = 0.05)


mm.30R <- mm(data4[data4$Share30 == 1 & data4$Rough_Ideology == "Right Wing",], f1, id = ~ID,  alpha = 0.05)
mm.30C <- mm(data4[data4$Share30 == 1 & data4$Rough_Ideology == "Center",], f1, id = ~ID,  alpha = 0.05)
mm.30L <- mm(data4[data4$Share30 == 1 & data4$Rough_Ideology == "Left Wing",], f1, id = ~ID,  alpha = 0.05)


mm.40R <- mm(data4[data4$Share40 == 1 & data4$Rough_Ideology == "Right Wing",], f1, id = ~ID,  alpha = 0.05)
mm.40C <- mm(data4[data4$Share40 == 1 & data4$Rough_Ideology == "Center",], f1, id = ~ID,  alpha = 0.05)
mm.40L <- mm(data4[data4$Share40 == 1 & data4$Rough_Ideology == "Left Wing",], f1, id = ~ID,  alpha = 0.05)


mm.50R <- mm(data4[data4$Share50 == 1 & data4$Rough_Ideology == "Right Wing",], f1, id = ~ID,  alpha = 0.05)
mm.50C <- mm(data4[data4$Share50 == 1 & data4$Rough_Ideology == "Center",], f1, id = ~ID,  alpha = 0.05)
mm.50L <- mm(data4[data4$Share50 == 1 & data4$Rough_Ideology == "Left Wing",], f1, id = ~ID,  alpha = 0.05)


ggData <- data.frame(rbind(cbind(fold = "10% Women, 90% Men Right", mm.10R),
                           cbind(fold = "20% Women, 80% Men Right", mm.20R),
                           cbind(fold = "30% Women, 70% Men Right", mm.30R),
                           cbind(fold = "40% Women, 60% Men Right", mm.40R),
                           cbind(fold = "50% Women, 50% Men Right", mm.50R),
                           cbind(fold = "10% Women, 90% Men Center", mm.10C),
                           cbind(fold = "20% Women, 80% Men Center", mm.20C),
                           cbind(fold = "30% Women, 70% Men Center", mm.30C),
                           cbind(fold = "40% Women, 60% Men Center", mm.40C),
                           cbind(fold = "50% Women, 50% Men Center", mm.50C),
                           cbind(fold = "10% Women, 90% Men Left", mm.10L),
                           cbind(fold = "20% Women, 80% Men Left", mm.20L),
                           cbind(fold = "30% Women, 70% Men Left", mm.30L),
                           cbind(fold = "40% Women, 60% Men Left", mm.40L),
                           cbind(fold = "50% Women, 50% Men Left", mm.50L)))

ggData$Ideology <- NA
ggData$Ideology <- ifelse(ggData$fold == "10% Women, 90% Men Right", "Right Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "20% Women, 80% Men Right", "Right Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "30% Women, 70% Men Right", "Right Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "40% Women, 60% Men Right", "Right Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "50% Women, 50% Men Right", "Right Wing", ggData$Ideology)

ggData$Ideology <- ifelse(ggData$fold == "10% Women, 90% Men Center", "Center", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "20% Women, 80% Men Center", "Center", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "30% Women, 70% Men Center", "Center", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "40% Women, 60% Men Center", "Center", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "50% Women, 50% Men Center", "Center", ggData$Ideology)

ggData$Ideology <- ifelse(ggData$fold == "10% Women, 90% Men Left", "Left Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "20% Women, 80% Men Left", "Left Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "30% Women, 70% Men Left", "Left Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "40% Women, 60% Men Left", "Left Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "50% Women, 50% Men Left", "Left Wing", ggData$Ideology)
ggData$Ideology <- as.factor(ggData$Ideology)


ggData$Ideology <- factor(as.character(ggData$Ideology), 
                          levels = rev(c("Right Wing","Center","Left Wing"
                          )))
ggData$Share <- NA
ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Right", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Right", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Right", "30% Women, 70% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "40% Women, 60% Men Right", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Right", "50% Women, 50% Men", ggData$Share)

ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Center", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Center", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Center", "30% Women, 70% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "40% Women, 60% Men Center", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Center", "50% Women, 50% Men", ggData$Share)

ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Left", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Left", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Left", "30% Women, 70% Men", ggData$Share)
ggData$Share<- ifelse(ggData$fold == "40% Women, 60% Men Left", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Left", "50% Women, 50% Men", ggData$Share)
ggData$Share <- as.factor(ggData$Share)



ggData$level <- factor(as.character(ggData$level), 
                       levels = rev(c("Under 30","30-39","40-49", "50-59", "60 and Older",
                                      "Taxation", "Energy Policy", "Gender Equality", "Immigration",
                                      "Law & Order", "Welfare",
                                      "Local Council", "State Legislature", "National Legislature",
                                      "High School", "University Degree", "PhD", "Same Position",
                                      "More Leftwing", "More Rightwing",
                                      "Man", "Woman"
                       )))


ggData$stat_label <- NA
ggData$stat_label[ggData$statistic == "mm"] <- "MM"

ggData$hline <- NA
ggData$hline[ggData$statistic == "mm"] <- 0.5


ggData$feature2 <- NA
ggData$feature2[ggData$feature == "Conjoint.Age"] = "Age"
ggData$feature2[ggData$feature == "Conjoint.Gender"] = "Gender"
ggData$feature2[ggData$feature == "Conjoint.Experience"] = "Experience"
ggData$feature2[ggData$feature == "Conjoint.MIP"] = "Issue"
ggData$feature2[ggData$feature == "Conjoint.Education"] = "Education"
ggData$feature2[ggData$feature == "Conjoint.Ideology"] = "Ideology"


ggData$feature2 <- as.factor(ggData$feature2)
ggData$feature2 <- (factor(ggData$feature2, levels = c("Gender", "Age", "Education", "Experience", "Ideology","Issue")))

ggData[is.na(ggData$lower),"lower"] <- 0
ggData[is.na(ggData$upper),"upper"] <- 0



dodge <- position_dodge(width=-0.5)
p = ggplot(ggData[ ggData$feature  %in% c("Conjoint.Gender"),], aes(group=Ideology ))
p = p + geom_pointrange(aes(x = as.factor(level), y = estimate, ymin = lower, ymax = upper, shape=Ideology), position=dodge)
p = p + geom_hline(aes(yintercept = hline), linetype = 2)
p = p + facet_grid(Share ~ "Aspirant Gender", scales = "free_y") + xlab("") + ylab("Marginal Means")
p = p + scale_shape_discrete(labels = c("Left", "Center", "Right")) 
p = p +  labs(shape = "Respondent\nIdeology") 
p = p + coord_flip() + theme(axis.text = element_text(size = rel(0.8)),
                             axis.ticks = element_line(colour = "black"),
                             legend.key = element_rect(fill = "white"),
                             plot.margin = unit(c(0, 0, 0, 0), "cm"),
                             panel.background = element_rect(fill = "white", colour = NA),
                             panel.border = element_rect(fill = NA, colour = "grey50"),
                             panel.grid.major = element_line(colour = "grey90", size = 0.2),
                             panel.grid.minor = element_line(colour = "grey98", size = 0.5),
                             strip.background = element_rect(fill = "white", colour = "grey50"),
                             strip.text.x = element_text(size = 12, colour = "black", face = "bold"),
                             strip.text.y = element_text(size = 5, colour = "black", face = "bold"))   
p




### FIGURE 3

data4$Share10 <- ifelse(data4$Conjoint.Share == "10 Prozent Frauen, 90 Prozent MÃ¤nner", 1,0)
data4$Share20 <- ifelse(data4$Conjoint.Share == "20 Prozent Frauen, 80 Prozent MÃ¤nner", 1,0)
data4$Share30 <- ifelse(data4$Conjoint.Share == "30 Prozent Frauen,  70 Prozent MÃ¤nner", 1,0)
data4$Share40 <- ifelse(data4$Conjoint.Share == "40 Prozent Frauen, 60 Prozent MÃ¤nner", 1,0)
data4$Share50 <- ifelse(data4$Conjoint.Share == "50 Prozent Frauen, 50 Prozent MÃ¤nner", 1,0)

mm.10M <- mm(data4[data4$Share10 == 1 & data4$Gender == "Man",], f1, id = ~ID,  alpha = 0.05)
mm.10W <- mm(data4[data4$Share10 == 1 & data4$Gender == "Woman",], f1, id = ~ID,  alpha = 0.05)

mm.20M <- mm(data4[data4$Share20 == 1 & data4$Gender == "Man",], f1, id = ~ID,  alpha = 0.05)
mm.20W <- mm(data4[data4$Share20 == 1 & data4$Gender == "Woman",], f1, id = ~ID,  alpha = 0.05)

mm.30M <- mm(data4[data4$Share30 == 1 & data4$Gender == "Man",], f1, id = ~ID,  alpha = 0.05)
mm.30W <- mm(data4[data4$Share30 == 1 & data4$Gender == "Woman",], f1, id = ~ID,  alpha = 0.05)

mm.40M <- mm(data4[data4$Share40 == 1 & data4$Gender == "Man",], f1, id = ~ID,  alpha = 0.05)
mm.40W <- mm(data4[data4$Share40 == 1 & data4$Gender == "Woman",], f1, id = ~ID,  alpha = 0.05)

mm.50M <- mm(data4[data4$Share50 == 1 & data4$Gender == "Man",], f1, id = ~ID,  alpha = 0.05)
mm.50W <- mm(data4[data4$Share50 == 1 & data4$Gender == "Woman",], f1, id = ~ID,  alpha = 0.05)

ggData <- data.frame(rbind(cbind(fold = "10% Women, 90% Men Men", mm.10M),
                           cbind(fold = "20% Women, 80% Men Men", mm.20M),
                           cbind(fold = "30% Women, 70% Men Men", mm.30M),
                           cbind(fold = "40% Women, 60% Men Men", mm.40M),
                           cbind(fold = "50% Women, 50% Men Men", mm.50M),
                           cbind(fold = "10% Women, 90% Men Women", mm.10W),
                           cbind(fold = "20% Women, 80% Men Women", mm.20W),
                           cbind(fold = "30% Women, 70% Men Women", mm.30W),
                           cbind(fold = "40% Women, 60% Men Women", mm.40W),
                           cbind(fold = "50% Women, 50% Men Women", mm.50W)))


ggData$Gender <- NA
ggData$Gender <- ifelse(ggData$fold == "10% Women, 90% Men Women", "Woman", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "20% Women, 80% Men Women", "Woman", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "30% Women, 70% Men Women", "Woman", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "40% Women, 60% Men Women", "Woman", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "50% Women, 50% Men Women", "Woman", ggData$Gender)

ggData$Gender <- ifelse(ggData$fold == "10% Women, 90% Men Men", "Man", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "20% Women, 80% Men Men", "Man", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "30% Women, 70% Men Men", "Man", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "40% Women, 60% Men Men", "Man", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "50% Women, 50% Men Men", "Man", ggData$Gender)

ggData$Share <- NA
ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Women", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Women", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Women", "30% Women, 70% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "40% Women, 60% Men Women", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Women", "50% Women, 50% Men", ggData$Share)

ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Men", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Men", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Men", "30% Women, 70% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "40% Women, 60% Men Men", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Men", "50% Women, 50% Men", ggData$Share)




ggData$level <- factor(as.character(ggData$level), 
                       levels = rev(c("Under 30","30-39","40-49", "50-59", "60 and Older",
                                      "Taxation", "Energy Policy", "Gender Equality", "Immigration",
                                      "Law & Order", "Welfare",
                                      "Local Council", "State Legislature", "National Legislature",
                                      "High School", "University Degree", "PhD", "Same Position",
                                      "More Leftwing", "More Rightwing",
                                      "Man", "Woman"
                       )))


ggData$stat_label <- NA
ggData$stat_label[ggData$statistic == "mm"] <- "MM"

ggData$hline <- NA
ggData$hline[ggData$statistic == "mm"] <- 0.5


ggData$feature2 <- NA
ggData$feature2[ggData$feature == "Conjoint.Age"] = "Age"
ggData$feature2[ggData$feature == "Conjoint.Gender"] = "Gender"
ggData$feature2[ggData$feature == "Conjoint.Experience"] = "Experience"
ggData$feature2[ggData$feature == "Conjoint.MIP"] = "Issue"
ggData$feature2[ggData$feature == "Conjoint.Education"] = "Education"
ggData$feature2[ggData$feature == "Conjoint.Ideology"] = "Ideology"


ggData$feature2 <- as.factor(ggData$feature2)
ggData$feature2 <- (factor(ggData$feature2, levels = c("Gender", "Age", "Education", "Experience", "Ideology","Issue")))

ggData[is.na(ggData$lower),"lower"] <- 0
ggData[is.na(ggData$upper),"upper"] <- 0

dodge <- position_dodge(width=-0.5)
p = ggplot(ggData[ ggData$feature  %in% c("Conjoint.Gender"),], aes(group=Gender ))
p = p + geom_pointrange(aes(x = as.factor(level), y = estimate, ymin = lower, ymax = upper, shape=Gender), position=dodge)
p = p + geom_hline(aes(yintercept = hline), linetype = 2)
p = p + facet_grid(Share ~ "Aspirant Gender", scales = "free_y") + xlab("") + ylab("Marginal Means")
p = p + scale_shape_discrete(labels = c("Man", "Woman")) 
p = p +  labs(shape = "Respondent\nGender") 
p = p + coord_flip() + theme(axis.text = element_text(size = rel(0.8)),
                             axis.ticks = element_line(colour = "black"),
                             legend.key = element_rect(fill = "white"),
                             plot.margin = unit(c(0, 0, 0, 0), "cm"),
                             panel.background = element_rect(fill = "white", colour = NA),
                             panel.border = element_rect(fill = NA, colour = "grey50"),
                             panel.grid.major = element_line(colour = "grey90", size = 0.2),
                             panel.grid.minor = element_line(colour = "grey98", size = 0.5),
                             strip.background = element_rect(fill = "white", colour = "grey50"),
                             strip.text.x = element_text(size = 10, colour = "black", face = "bold"),
                             strip.text.y = element_text(size = 5, colour = "black", face = "bold"))   
p





###################################
# Produce figures in the appendix #
###################################

### FIGURE 3

ggData <- data.frame(mm.all)
ggData$feature <- as.character(ggData$feature)


ggData$level <- factor(as.character(ggData$level), 
                       levels = rev(c("Man", "Woman",
                                      "Under 30","30-39","40-49", "50-59", "60 and Older",
                                      "Taxation", "Energy Policy", "Gender Equality", "Immigration",
                                      "Law & Order", "Welfare", 
                                      "Local Council", "State Legislature", "National Legislature",
                                      "High School", "University Degree", "PhD", "Same Position",
                                      "More Leftwing", "More Rightwing"
                       )))

ggData$stat_label <- NA
ggData$stat_label[ggData$statistic == "mm"] <- "Pooled Sample"


ggData$hline <- NA
ggData$hline[ggData$statistic == "mm"] <- 0.5


ggData$feature2 <- NA
ggData$feature2[ggData$feature == "Conjoint.Age"] = "Age"
ggData$feature2[ggData$feature == "Conjoint.Experience"] = "Experience"
ggData$feature2[ggData$feature == "Conjoint.MIP"] = "Issue"
ggData$feature2[ggData$feature == "Conjoint.Education"] = "Education"
ggData$feature2[ggData$feature == "Conjoint.Ideology"] = "Ideology"
ggData$feature2[ggData$feature == "Conjoint.Gender"] = "Gender"

ggData$feature2 <- as.factor(ggData$feature2)
ggData$feature2 <- (factor(ggData$feature2, levels = c("Gender", "Age", "Education", "Experience", "Ideology","Issue")))



ggData[is.na(ggData$lower),"lower"] <- 0
ggData[is.na(ggData$upper),"upper"] <- 0

p = ggplot(ggData[ggData$feature %in% c("Conjoint.Age","Conjoint.MIP","Conjoint.Experience","Conjoint.Education","Conjoint.Ideology", "Conjoint.Gender"),])
p = p + geom_pointrange(aes(x = as.factor(level), y = estimate, ymin = lower, ymax = upper))
p = p + geom_hline(aes(yintercept = hline), linetype = 2)
p = p + facet_grid(feature2 ~ stat_label, scales = "free") + xlab("") +  ylab("Marginal Means") 
p = p + coord_flip() + theme(axis.text = element_text(size = rel(0.8)),
                             axis.ticks = element_line(colour = "black"),
                             legend.key = element_rect(fill = "white"),
                             plot.margin = unit(c(0, 0, 0, 0), "cm"),
                             panel.background = element_rect(fill = "white", colour = NA),
                             panel.border = element_rect(fill = NA, colour = "grey50"),
                             panel.grid.major = element_line(colour = "grey90", size = 0.2),
                             panel.grid.minor = element_line(colour = "grey98", size = 0.5),
                             strip.background = element_rect(fill = "white", colour = "grey50"),
                             strip.text.x = element_text(size = 12, colour = "black", face = "bold"),
                             strip.text.y = element_text(size = 10, colour = "black", face = "bold"))   
p




### FIGURE 4

data4$Share10 <- ifelse(data4$Conjoint.Share == "10 Prozent Frauen, 90 Prozent MÃ¤nner", 1,0)
data4$Share20 <- ifelse(data4$Conjoint.Share == "20 Prozent Frauen, 80 Prozent MÃ¤nner", 1,0)
data4$Share30 <- ifelse(data4$Conjoint.Share == "30 Prozent Frauen,  70 Prozent MÃ¤nner", 1,0)
data4$Share40 <- ifelse(data4$Conjoint.Share == "40 Prozent Frauen, 60 Prozent MÃ¤nner", 1,0)
data4$Share50 <- ifelse(data4$Conjoint.Share == "50 Prozent Frauen, 50 Prozent MÃ¤nner", 1,0)

mm.10AT <- mm(data4[data4$Share10 == 1 & data4$Country == "Ã\u0096sterreich",], f1, id = ~ID,  alpha = 0.05)
mm.10CH <- mm(data4[data4$Share10 == 1 & data4$Country == "Schweiz",], f1, id = ~ID,  alpha = 0.05)
mm.10DE <- mm(data4[data4$Share10 == 1 & data4$Country == "Deutschland",], f1, id = ~ID,  alpha = 0.05)


mm.20AT <- mm(data4[data4$Share20 == 1 & data4$Country == "Ã\u0096sterreich",], f1, id = ~ID,  alpha = 0.05)
mm.20CH <- mm(data4[data4$Share20 == 1 & data4$Country == "Schweiz",], f1, id = ~ID,  alpha = 0.05)
mm.20DE <- mm(data4[data4$Share20 == 1 & data4$Country == "Deutschland",], f1, id = ~ID,  alpha = 0.05)


mm.30AT <- mm(data4[data4$Share30 == 1 & data4$Country == "Ã\u0096sterreich",], f1, id = ~ID,  alpha = 0.05)
mm.30CH <- mm(data4[data4$Share30 == 1 & data4$Country == "Schweiz",], f1, id = ~ID,  alpha = 0.05)
mm.30DE <- mm(data4[data4$Share30 == 1 & data4$Country == "Deutschland",], f1, id = ~ID,  alpha = 0.05)


mm.40AT <- mm(data4[data4$Share40 == 1 & data4$Country == "Ã\u0096sterreich",], f1, id = ~ID,  alpha = 0.05)
mm.40CH <- mm(data4[data4$Share40 == 1 & data4$Country == "Schweiz",], f1, id = ~ID,  alpha = 0.05)
mm.40DE <- mm(data4[data4$Share40 == 1 & data4$Country == "Deutschland",], f1, id = ~ID,  alpha = 0.05)


mm.50AT <- mm(data4[data4$Share50 == 1 & data4$Country == "Ã\u0096sterreich",], f1, id = ~ID,  alpha = 0.05)
mm.50CH <- mm(data4[data4$Share50 == 1 & data4$Country == "Schweiz",], f1, id = ~ID,  alpha = 0.05)
mm.50DE <- mm(data4[data4$Share50 == 1 & data4$Country == "Deutschland",], f1, id = ~ID,  alpha = 0.05)


ggData <- data.frame(rbind(cbind(fold = "10% Women, 90% Men Austria", mm.10AT),
                           cbind(fold = "20% Women, 80% Men Austria", mm.20AT),
                           cbind(fold = "30% Women, 70% Men Austria", mm.30AT),
                           cbind(fold = "40% Women, 60% Men Austria", mm.40AT),
                           cbind(fold = "50% Women, 50% Men Austria", mm.50AT),
                           cbind(fold = "10% Women, 90% Men Germany", mm.10DE),
                           cbind(fold = "20% Women, 80% Men Germany", mm.20DE),
                           cbind(fold = "30% Women, 70% Men Germany", mm.30DE),
                           cbind(fold = "40% Women, 60% Men Germany", mm.40DE),
                           cbind(fold = "50% Women, 50% Men Germany", mm.50DE),
                           cbind(fold = "10% Women, 90% Men Switzerland", mm.10CH),
                           cbind(fold = "20% Women, 80% Men Switzerland", mm.20CH),
                           cbind(fold = "30% Women, 70% Men Switzerland", mm.30CH),
                           cbind(fold = "40% Women, 60% Men Switzerland", mm.40CH),
                           cbind(fold = "50% Women, 50% Men Switzerland", mm.50CH)))

ggData$Country <- NA
ggData$Country <- ifelse(ggData$fold == "10% Women, 90% Men Austria", "Austria", ggData$Country)
ggData$Country <- ifelse(ggData$fold == "20% Women, 80% Men Austria", "Austria", ggData$Country)
ggData$Country <- ifelse(ggData$fold == "30% Women, 70% Men Austria", "Austria", ggData$Country)
ggData$Country <- ifelse(ggData$fold == "40% Women, 60% Men Austria", "Austria", ggData$Country)
ggData$Country <- ifelse(ggData$fold == "50% Women, 50% Men Austria", "Austria", ggData$Country)

ggData$Country <- ifelse(ggData$fold == "10% Women, 90% Men Germany", "Germany", ggData$Country)
ggData$Country <- ifelse(ggData$fold == "20% Women, 80% Men Germany", "Germany", ggData$Country)
ggData$Country <- ifelse(ggData$fold == "30% Women, 70% Men Germany", "Germany", ggData$Country)
ggData$Country <- ifelse(ggData$fold == "40% Women, 60% Men Germany", "Germany", ggData$Country)
ggData$Country <- ifelse(ggData$fold == "50% Women, 50% Men Germany", "Germany", ggData$Country)


ggData$Country <- ifelse(ggData$fold == "10% Women, 90% Men Switzerland", "Switzerland", ggData$Country)
ggData$Country <- ifelse(ggData$fold == "20% Women, 80% Men Switzerland", "Switzerland", ggData$Country)
ggData$Country <- ifelse(ggData$fold == "30% Women, 70% Men Switzerland", "Switzerland", ggData$Country)
ggData$Country <- ifelse(ggData$fold == "40% Women, 60% Men Switzerland", "Switzerland", ggData$Country)
ggData$Country <- ifelse(ggData$fold == "50% Women, 50% Men Switzerland", "Switzerland", ggData$Country)
ggData$Country <- as.factor(ggData$Country)

ggData$Share <- NA
ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Austria", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Austria", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Austria", "30% Women, 70% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "40% Women, 60% Men Austria", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Austria", "50% Women, 50% Men", ggData$Share)

ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Germany", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Germany", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Germany", "30% Women, 70% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "40% Women, 60% Men Germany", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Germany", "50% Women, 50% Men", ggData$Share)

ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Switzerland", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Switzerland", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Switzerland", "30% Women, 70% Men", ggData$Share)
ggData$Share<- ifelse(ggData$fold == "40% Women, 60% Men Switzerland", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Switzerland", "50% Women, 50% Men", ggData$Share)
ggData$Share <- as.factor(ggData$Share)



ggData$level <- factor(as.character(ggData$level), 
                       levels = rev(c("Under 30","30-39","40-49", "50-59", "60 and Older",
                                      "Taxation", "Energy Policy", "Gender Equality", "Immigration",
                                      "Law & Order", "Welfare",
                                      "Local Council", "State Legislature", "National Legislature",
                                      "High School", "University Degree", "PhD", "Same Position",
                                      "More Leftwing", "More Rightwing",
                                      "Man", "Woman"
                       )))


ggData$stat_label <- NA
ggData$stat_label[ggData$statistic == "mm"] <- "MM"

ggData$hline <- NA
ggData$hline[ggData$statistic == "mm"] <- 0.5


ggData$feature2 <- NA
ggData$feature2[ggData$feature == "Conjoint.Age"] = "Age"
ggData$feature2[ggData$feature == "Conjoint.Gender"] = "Gender"
ggData$feature2[ggData$feature == "Conjoint.Experience"] = "Experience"
ggData$feature2[ggData$feature == "Conjoint.MIP"] = "Issue"
ggData$feature2[ggData$feature == "Conjoint.Education"] = "Education"
ggData$feature2[ggData$feature == "Conjoint.Ideology"] = "Ideology"



ggData$feature2 <- as.factor(ggData$feature2)
ggData$feature2 <- (factor(ggData$feature2, levels = c("Gender", "Age", "Education", "Experience", "Ideology","Issue")))

ggData[is.na(ggData$lower),"lower"] <- 0
ggData[is.na(ggData$upper),"upper"] <- 0


dodge <- position_dodge(width=-0.5)
p = ggplot(ggData[ ggData$feature  %in% c("Conjoint.Gender"),], aes(group=Country))
p = p + geom_pointrange(aes(x = as.factor(level), y = estimate, ymin = lower, ymax = upper, shape=Country), position=dodge)
p = p + geom_hline(aes(yintercept = hline), linetype = 2)
p = p + facet_grid(Share ~ "Aspirant Gender", scales = "free_y") + xlab("") + ylab("Marginal Means")
p = p + scale_shape_discrete(labels = c("Austria", "Germany", "Switzerland")) 
p = p +  labs(shape = "Respondent\nCountry") 
p = p + coord_flip() + theme(axis.text = element_text(size = rel(0.8)),
                             axis.ticks = element_line(colour = "black"),
                             legend.key = element_rect(fill = "white"),
                             plot.margin = unit(c(0, 0, 0, 0), "cm"),
                             panel.background = element_rect(fill = "white", colour = NA),
                             panel.border = element_rect(fill = NA, colour = "grey50"),
                             panel.grid.major = element_line(colour = "grey90", size = 0.2),
                             panel.grid.minor = element_line(colour = "grey98", size = 0.5),
                             strip.background = element_rect(fill = "white", colour = "grey50"),
                             strip.text.x = element_text(size = 10, colour = "black", face = "bold"),
                             strip.text.y = element_text(size = 6, colour = "black", face = "bold"))   
p



### FIGURE 5

data4$Share10 <- ifelse(data4$Conjoint.Share == "10 Prozent Frauen, 90 Prozent MÃ¤nner", 1,0)
data4$Share20 <- ifelse(data4$Conjoint.Share == "20 Prozent Frauen, 80 Prozent MÃ¤nner", 1,0)
data4$Share30 <- ifelse(data4$Conjoint.Share == "30 Prozent Frauen,  70 Prozent MÃ¤nner", 1,0)
data4$Share40 <- ifelse(data4$Conjoint.Share == "40 Prozent Frauen, 60 Prozent MÃ¤nner", 1,0)
data4$Share50 <- ifelse(data4$Conjoint.Share == "50 Prozent Frauen, 50 Prozent MÃ¤nner", 1,0)

mm.10Y <- mm(data4[data4$Share10 == 1 & data4$Quota == "Yes",], f1, id = ~ID,  alpha = 0.05)
mm.10N <- mm(data4[data4$Share10 == 1 & data4$Quota == "No",], f1, id = ~ID,  alpha = 0.05)

mm.20Y <- mm(data4[data4$Share20 == 1 & data4$Quota == "Yes",], f1, id = ~ID,  alpha = 0.05)
mm.20N <- mm(data4[data4$Share20 == 1 & data4$Quota == "No",], f1, id = ~ID,  alpha = 0.05)

mm.30Y <- mm(data4[data4$Share30 == 1 & data4$Quota == "Yes",], f1, id = ~ID,  alpha = 0.05)
mm.30N <- mm(data4[data4$Share30 == 1 & data4$Quota == "No",], f1, id = ~ID,  alpha = 0.05)

mm.40Y <- mm(data4[data4$Share40 == 1 & data4$Quota == "Yes",], f1, id = ~ID,  alpha = 0.05)
mm.40N <- mm(data4[data4$Share40 == 1 & data4$Quota == "No",], f1, id = ~ID,  alpha = 0.05)

mm.50Y <- mm(data4[data4$Share50 == 1 & data4$Quota == "Yes",], f1, id = ~ID,  alpha = 0.05)
mm.50N <- mm(data4[data4$Share50 == 1 & data4$Quota == "No",], f1, id = ~ID,  alpha = 0.05)

ggData <- data.frame(rbind(cbind(fold = "10% Women, 90% Men Y", mm.10Y),
                           cbind(fold = "20% Women, 80% Men Y", mm.20Y),
                           cbind(fold = "30% Women, 70% Men Y", mm.30Y),
                           cbind(fold = "40% Women, 60% Men Y", mm.40Y),
                           cbind(fold = "50% Women, 50% Men Y", mm.50Y),
                           cbind(fold = "10% Women, 90% Men N", mm.10N),
                           cbind(fold = "20% Women, 80% Men N", mm.20N),
                           cbind(fold = "30% Women, 70% Men N", mm.30N),
                           cbind(fold = "40% Women, 60% Men N", mm.40N),
                           cbind(fold = "50% Women, 50% Men N", mm.50N)))


ggData$Quota <- NA
ggData$Quota <- ifelse(ggData$fold == "10% Women, 90% Men Y", "Quota", ggData$Quota)
ggData$Quota <- ifelse(ggData$fold == "20% Women, 80% Men Y", "Quota", ggData$Quota)
ggData$Quota <- ifelse(ggData$fold == "30% Women, 70% Men Y", "Quota", ggData$Quota)
ggData$Quota <- ifelse(ggData$fold == "40% Women, 60% Men Y", "Quota", ggData$Quota)
ggData$Quota <- ifelse(ggData$fold == "50% Women, 50% Men Y", "Quota", ggData$Quota)

ggData$Quota <- ifelse(ggData$fold == "10% Women, 90% Men N", "No Quota", ggData$Quota)
ggData$Quota <- ifelse(ggData$fold == "20% Women, 80% Men N", "No Quota", ggData$Quota)
ggData$Quota <- ifelse(ggData$fold == "30% Women, 70% Men N", "No Quota", ggData$Quota)
ggData$Quota <- ifelse(ggData$fold == "40% Women, 60% Men N", "No Quota", ggData$Quota)
ggData$Quota <- ifelse(ggData$fold == "50% Women, 50% Men N", "No Quota", ggData$Quota)

ggData$Share <- NA
ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Y", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Y", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Y", "30% Women, 70% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "40% Women, 60% Men Y", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Y", "50% Women, 50% Men", ggData$Share)

ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men N", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men N", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men N", "30% Women, 70% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "40% Women, 60% Men N", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men N", "50% Women, 50% Men", ggData$Share)




ggData$level <- factor(as.character(ggData$level), 
                       levels = rev(c("Under 30","30-39","40-49", "50-59", "60 and Older",
                                      "Taxation", "Energy Policy", "Gender Equality", "Immigration",
                                      "Law & Order", "Welfare",
                                      "Local Council", "State Legislature", "National Legislature",
                                      "High School", "University Degree", "PhD", "Same Position",
                                      "More Leftwing", "More Rightwing",
                                      "Man", "Woman"
                       )))


ggData$stat_label <- NA
ggData$stat_label[ggData$statistic == "mm"] <- "MM"

ggData$hline <- NA
ggData$hline[ggData$statistic == "mm"] <- 0.5


ggData$feature2 <- NA
ggData$feature2[ggData$feature == "Conjoint.Age"] = "Age"
ggData$feature2[ggData$feature == "Conjoint.Gender"] = "Gender"
ggData$feature2[ggData$feature == "Conjoint.Experience"] = "Experience"
ggData$feature2[ggData$feature == "Conjoint.MIP"] = "Issue"
ggData$feature2[ggData$feature == "Conjoint.Education"] = "Education"
ggData$feature2[ggData$feature == "Conjoint.Ideology"] = "Ideology"


ggData$feature2 <- as.factor(ggData$feature2)
ggData$feature2 <- (factor(ggData$feature2, levels = c("Gender", "Age", "Education", "Experience", "Ideology","Issue")))

ggData[is.na(ggData$lower),"lower"] <- 0
ggData[is.na(ggData$upper),"upper"] <- 0

dodge <- position_dodge(width=-0.5)
p = ggplot(ggData[ ggData$feature  %in% c("Conjoint.Gender"),], aes(group=Quota))
p = p + geom_pointrange(aes(x = as.factor(level), y = estimate, ymin = lower, ymax = upper, shape=Quota), position=dodge)
p = p + geom_hline(aes(yintercept = hline), linetype = 2)
p = p + facet_grid(Share ~ "Aspirant Gender", scales = "free_y") + xlab("") + ylab("Marginal Means")
p = p + scale_shape_discrete(labels = c("No Quota", "Quota")) 
p = p +  labs(shape = "Gender Quota") 
p = p + coord_flip() + theme(axis.text = element_text(size = rel(0.8)),
                             axis.ticks = element_line(colour = "black"),
                             legend.key = element_rect(fill = "white"),
                             plot.margin = unit(c(0, 0, 0, 0), "cm"),
                             panel.background = element_rect(fill = "white", colour = NA),
                             panel.border = element_rect(fill = NA, colour = "grey50"),
                             panel.grid.major = element_line(colour = "grey90", size = 0.2),
                             panel.grid.minor = element_line(colour = "grey98", size = 0.5),
                             strip.background = element_rect(fill = "white", colour = "grey50"),
                             strip.text.x = element_text(size = 10, colour = "black", face = "bold"),
                             strip.text.y = element_text(size = 6, colour = "black", face = "bold"))   
p




### FIGURE 6

data4$Share10 <- ifelse(data4$Conjoint.Share == "10 Prozent Frauen, 90 Prozent MÃ¤nner", 1,0)
data4$Share20 <- ifelse(data4$Conjoint.Share == "20 Prozent Frauen, 80 Prozent MÃ¤nner", 1,0)
data4$Share30 <- ifelse(data4$Conjoint.Share == "30 Prozent Frauen,  70 Prozent MÃ¤nner", 1,0)
data4$Share40 <- ifelse(data4$Conjoint.Share == "40 Prozent Frauen, 60 Prozent MÃ¤nner", 1,0)
data4$Share50 <- ifelse(data4$Conjoint.Share == "50 Prozent Frauen, 50 Prozent MÃ¤nner", 1,0)

mm.10 <- mm(data4[data4$Share10 == 1,], f1, id = ~ID,  alpha = 0.05)
mm.20 <- mm(data4[data4$Share20 == 1,], f1, id = ~ID,  alpha = 0.05)
mm.30 <- mm(data4[data4$Share30 == 1,], f1, id = ~ID,  alpha = 0.05)
mm.40 <- mm(data4[data4$Share40 == 1,], f1, id = ~ID,  alpha = 0.05)
mm.50 <- mm(data4[data4$Share50 == 1,], f1, id = ~ID,  alpha = 0.05)


ggData <- data.frame(rbind(cbind(fold = "10% Women, 90% Men", mm.10),
                           cbind(fold = "20% Women, 80% Men", mm.20),
                           cbind(fold = "30% Women, 70% Men", mm.30),
                           cbind(fold = "40% Women, 60% Men", mm.40),
                           cbind(fold = "50% Women, 50% Men", mm.50)))


ggData$level <- factor(as.character(ggData$level), 
                       levels = rev(c("Under 30","30-39","40-49", "50-59", "60 and Older",
                                      "Taxation", "Energy Policy", "Gender Equality", "Immigration",
                                      "Law & Order", "Welfare",
                                      "Local Council", "State Legislature", "National Legislature",
                                      "High School", "University Degree", "PhD", "Same Position",
                                      "More Leftwing", "More Rightwing",
                                      "Man", "Woman"
                       )))


ggData$stat_label <- NA
ggData$stat_label[ggData$statistic == "mm"] <- "Pooled Sample"

ggData$hline <- NA
ggData$hline[ggData$statistic == "mm"] <- 0.5


ggData$feature2 <- NA
ggData$feature2[ggData$feature == "Conjoint.Age"] = "Age"
ggData$feature2[ggData$feature == "Conjoint.Gender"] = "Aspirant Gender"
ggData$feature2[ggData$feature == "Conjoint.Experience"] = "Experience"
ggData$feature2[ggData$feature == "Conjoint.MIP"] = "Issue"
ggData$feature2[ggData$feature == "Conjoint.Education"] = "Education"
ggData$feature2[ggData$feature == "Conjoint.Ideology"] = "Ideology"


ggData$feature2 <- as.factor(ggData$feature2)
ggData$feature2 <- (factor(ggData$feature2, levels = c("Aspirant Gender")))

ggData[is.na(ggData$lower),"lower"] <- 0
ggData[is.na(ggData$upper),"upper"] <- 0



ggData$feature2 <- NA
#ggData$feature2[ggData$feature == "Conjoint.Age"] = "Age"
ggData$feature2[ggData$feature == "Conjoint.Education"] = "Education"
ggData$feature2[ggData$feature == "Conjoint.Experience"] = "Experience"
#ggData$feature2[ggData$feature == "Conjoint.MIP"] = "Issue"
#ggData$feature2[ggData$feature == "Conjoint.Ideology"] = "Ideology"


ggData$feature2 <- as.factor(ggData$feature2)
#ggData$feature2 <- (factor(ggData$feature2, levels = c("Gender")))

ggData[is.na(ggData$lower),"lower"] <- 0
ggData[is.na(ggData$upper),"upper"] <- 0


p = ggplot(ggData[ggData$feature %in% c("Conjoint.Experience", "Conjoint.Education"),])
p = p + geom_pointrange(aes(x = as.factor(level), y = estimate, ymin = lower, ymax = upper))
p = p + geom_hline(aes(yintercept = hline), linetype = 2)
p = p + facet_grid(fold~ feature2, scales = "fixed") + xlab("") + ylab("Marginal Means") 
p = p + coord_flip() + theme(axis.text = element_text(size = rel(0.8)),
                             axis.ticks = element_line(colour = "black"),
                             legend.key = element_rect(fill = "white"),
                             plot.margin = unit(c(0, 0, 0, 0), "cm"),
                             panel.background = element_rect(fill = "white", colour = NA),
                             panel.border = element_rect(fill = NA, colour = "grey50"),
                             panel.grid.major = element_line(colour = "grey90", size = 0.2),
                             panel.grid.minor = element_line(colour = "grey98", size = 0.5),
                             strip.background = element_rect(fill = "white", colour = "grey50"),
                             strip.text.x = element_text(size = 12, colour = "black", face = "bold"),
                             strip.text.y = element_text(size = 5, colour = "black", face = "bold"))   
p



### FIGURE 7

ggData$feature2 <- NA
#ggData$feature2[ggData$feature == "Conjoint.Age"] = "Age"
#ggData$feature2[ggData$feature == "Conjoint.Education"] = "Education"
#ggData$feature2[ggData$feature == "Conjoint.Experience"] = "Experience"
ggData$feature2[ggData$feature == "Conjoint.MIP"] = "Issue"
ggData$feature2[ggData$feature == "Conjoint.Ideology"] = "Ideology"


ggData$feature2 <- as.factor(ggData$feature2)
#ggData$feature2 <- (factor(ggData$feature2, levels = c("Gender")))

ggData[is.na(ggData$lower),"lower"] <- 0
ggData[is.na(ggData$upper),"upper"] <- 0


p = ggplot(ggData[ggData$feature %in% c("Conjoint.Ideology", "Conjoint.MIP"),])
p = p + geom_pointrange(aes(x = as.factor(level), y = estimate, ymin = lower, ymax = upper))
p = p + geom_hline(aes(yintercept = hline), linetype = 2)
p = p + facet_grid(fold~ feature2, scales = "fixed") + xlab("") + ylab("Marginal Means") 
p = p + coord_flip() + theme(axis.text = element_text(size = rel(0.8)),
                             axis.ticks = element_line(colour = "black"),
                             legend.key = element_rect(fill = "white"),
                             plot.margin = unit(c(0, 0, 0, 0), "cm"),
                             panel.background = element_rect(fill = "white", colour = NA),
                             panel.border = element_rect(fill = NA, colour = "grey50"),
                             panel.grid.major = element_line(colour = "grey90", size = 0.2),
                             panel.grid.minor = element_line(colour = "grey98", size = 0.5),
                             strip.background = element_rect(fill = "white", colour = "grey50"),
                             strip.text.x = element_text(size = 12, colour = "black", face = "bold"),
                             strip.text.y = element_text(size = 5, colour = "black", face = "bold"))   
p





### FIGURE 8

dataAT <- data4[ which(data4$Country=='Ã\u0096sterreich'), ]

dataAT$Share10 <- ifelse(dataAT$Conjoint.Share == "10 Prozent Frauen, 90 Prozent MÃ¤nner", 1,0)
dataAT$Share20 <- ifelse(dataAT$Conjoint.Share == "20 Prozent Frauen, 80 Prozent MÃ¤nner", 1,0)
dataAT$Share30 <- ifelse(dataAT$Conjoint.Share == "30 Prozent Frauen,  70 Prozent MÃ¤nner", 1,0)
dataAT$Share40 <- ifelse(dataAT$Conjoint.Share == "40 Prozent Frauen, 60 Prozent MÃ¤nner", 1,0)
dataAT$Share50 <- ifelse(dataAT$Conjoint.Share == "50 Prozent Frauen, 50 Prozent MÃ¤nner", 1,0)

mm.10R <- mm(dataAT[dataAT$Share10 == 1 & dataAT$Rough_Ideology == "Right Wing",], f1, id = ~ID,  alpha = 0.05)
mm.10C <- mm(dataAT[dataAT$Share10 == 1 & dataAT$Rough_Ideology == "Center",], f1, id = ~ID,  alpha = 0.05)
mm.10L <- mm(dataAT[dataAT$Share10 == 1 & dataAT$Rough_Ideology == "Left Wing",], f1, id = ~ID,  alpha = 0.05)


mm.20R <- mm(dataAT[dataAT$Share20 == 1 & dataAT$Rough_Ideology == "Right Wing",], f1, id = ~ID,  alpha = 0.05)
mm.20C <- mm(dataAT[dataAT$Share20 == 1 & dataAT$Rough_Ideology == "Center",], f1, id = ~ID,  alpha = 0.05)
mm.20L <- mm(dataAT[dataAT$Share20 == 1 & dataAT$Rough_Ideology == "Left Wing",], f1, id = ~ID,  alpha = 0.05)


mm.30R <- mm(dataAT[dataAT$Share30 == 1 & dataAT$Rough_Ideology == "Right Wing",], f1, id = ~ID,  alpha = 0.05)
mm.30C <- mm(dataAT[dataAT$Share30 == 1 & dataAT$Rough_Ideology == "Center",], f1, id = ~ID,  alpha = 0.05)
mm.30L <- mm(dataAT[dataAT$Share30 == 1 & dataAT$Rough_Ideology == "Left Wing",], f1, id = ~ID,  alpha = 0.05)


mm.40R <- mm(dataAT[dataAT$Share40 == 1 & dataAT$Rough_Ideology == "Right Wing",], f1, id = ~ID,  alpha = 0.05)
mm.40C <- mm(dataAT[dataAT$Share40 == 1 & dataAT$Rough_Ideology == "Center",], f1, id = ~ID,  alpha = 0.05)
mm.40L <- mm(dataAT[dataAT$Share40 == 1 & dataAT$Rough_Ideology == "Left Wing",], f1, id = ~ID,  alpha = 0.05)


mm.50R <- mm(dataAT[dataAT$Share50 == 1 & dataAT$Rough_Ideology == "Right Wing",], f1, id = ~ID,  alpha = 0.05)
mm.50C <- mm(dataAT[dataAT$Share50 == 1 & dataAT$Rough_Ideology == "Center",], f1, id = ~ID,  alpha = 0.05)
mm.50L <- mm(dataAT[dataAT$Share50 == 1 & dataAT$Rough_Ideology == "Left Wing",], f1, id = ~ID,  alpha = 0.05)


ggData <- data.frame(rbind(cbind(fold = "10% Women, 90% Men Right", mm.10R),
                           cbind(fold = "20% Women, 80% Men Right", mm.20R),
                           cbind(fold = "30% Women, 70% Men Right", mm.30R),
                           cbind(fold = "40% Women, 60% Men Right", mm.40R),
                           cbind(fold = "50% Women, 50% Men Right", mm.50R),
                           cbind(fold = "10% Women, 90% Men Center", mm.10C),
                           cbind(fold = "20% Women, 80% Men Center", mm.20C),
                           cbind(fold = "30% Women, 70% Men Center", mm.30C),
                           cbind(fold = "40% Women, 60% Men Center", mm.40C),
                           cbind(fold = "50% Women, 50% Men Center", mm.50C),
                           cbind(fold = "10% Women, 90% Men Left", mm.10L),
                           cbind(fold = "20% Women, 80% Men Left", mm.20L),
                           cbind(fold = "30% Women, 70% Men Left", mm.30L),
                           cbind(fold = "40% Women, 60% Men Left", mm.40L),
                           cbind(fold = "50% Women, 50% Men Left", mm.50L)))

ggData$Ideology <- NA
ggData$Ideology <- ifelse(ggData$fold == "10% Women, 90% Men Right", "Right Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "20% Women, 80% Men Right", "Right Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "30% Women, 70% Men Right", "Right Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "40% Women, 60% Men Right", "Right Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "50% Women, 50% Men Right", "Right Wing", ggData$Ideology)

ggData$Ideology <- ifelse(ggData$fold == "10% Women, 90% Men Center", "Center", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "20% Women, 80% Men Center", "Center", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "30% Women, 70% Men Center", "Center", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "40% Women, 60% Men Center", "Center", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "50% Women, 50% Men Center", "Center", ggData$Ideology)

ggData$Ideology <- ifelse(ggData$fold == "10% Women, 90% Men Left", "Left Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "20% Women, 80% Men Left", "Left Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "30% Women, 70% Men Left", "Left Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "40% Women, 60% Men Left", "Left Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "50% Women, 50% Men Left", "Left Wing", ggData$Ideology)
ggData$Ideology <- as.factor(ggData$Ideology)



ggData$Ideology <- factor(as.character(ggData$Ideology), 
                          levels = rev(c("Right Wing","Center","Left Wing"
                          )))

ggData$Share <- NA
ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Right", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Right", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Right", "30% Women, 70% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "40% Women, 60% Men Right", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Right", "50% Women, 50% Men", ggData$Share)

ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Center", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Center", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Center", "30% Women, 70% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "40% Women, 60% Men Center", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Center", "50% Women, 50% Men", ggData$Share)

ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Left", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Left", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Left", "30% Women, 70% Men", ggData$Share)
ggData$Share<- ifelse(ggData$fold == "40% Women, 60% Men Left", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Left", "50% Women, 50% Men", ggData$Share)
ggData$Share <- as.factor(ggData$Share)



ggData$level <- factor(as.character(ggData$level), 
                       levels = rev(c("Under 30","30-39","40-49", "50-59", "60 and Older",
                                      "Taxation", "Energy Policy", "Gender Equality", "Immigration",
                                      "Law & Order", "Welfare",
                                      "Local Council", "State Legislature", "National Legislature",
                                      "High School", "University Degree", "PhD", "Same Position",
                                      "More Leftwing", "More Rightwing",
                                      "Man", "Woman"
                       )))


ggData$stat_label <- NA
ggData$stat_label[ggData$statistic == "mm"] <- "MM"

ggData$hline <- NA
ggData$hline[ggData$statistic == "mm"] <- 0.5


ggData$feature2 <- NA
ggData$feature2[ggData$feature == "Conjoint.Age"] = "Age"
ggData$feature2[ggData$feature == "Conjoint.Gender"] = "Gender"
ggData$feature2[ggData$feature == "Conjoint.Experience"] = "Experience"
ggData$feature2[ggData$feature == "Conjoint.MIP"] = "Issue"
ggData$feature2[ggData$feature == "Conjoint.Education"] = "Education"
ggData$feature2[ggData$feature == "Conjoint.Ideology"] = "Ideology"


ggData$feature2 <- as.factor(ggData$feature2)
ggData$feature2 <- (factor(ggData$feature2, levels = c("Gender", "Age", "Education", "Experience", "Ideology","Issue")))

ggData[is.na(ggData$lower),"lower"] <- 0
ggData[is.na(ggData$upper),"upper"] <- 0



dodge <- position_dodge(width=-0.5)
p = ggplot(ggData[ ggData$feature  %in% c("Conjoint.Gender"),], aes(group=Ideology ))
p = p + geom_pointrange(aes(x = as.factor(level), y = estimate, ymin = lower, ymax = upper, shape=Ideology), position=dodge)
p = p + geom_hline(aes(yintercept = hline), linetype = 2)
p = p + facet_grid(Share ~ "Aspirant Gender", scales = "free_y") + xlab("") + ylab("Marginal Means")
p = p + scale_shape_discrete(labels = c("Left", "Center", "Right")) 
p = p +  labs(shape = "Respondent\nIdeology") 
p = p + coord_flip() + theme(axis.text = element_text(size = rel(0.8)),
                             axis.ticks = element_line(colour = "black"),
                             legend.key = element_rect(fill = "white"),
                             plot.margin = unit(c(0, 0, 0, 0), "cm"),
                             panel.background = element_rect(fill = "white", colour = NA),
                             panel.border = element_rect(fill = NA, colour = "grey50"),
                             panel.grid.major = element_line(colour = "grey90", size = 0.2),
                             panel.grid.minor = element_line(colour = "grey98", size = 0.5),
                             strip.background = element_rect(fill = "white", colour = "grey50"),
                             strip.text.x = element_text(size = 10, colour = "black", face = "bold"),
                             strip.text.y = element_text(size = 6, colour = "black", face = "bold"))   
p




### FIGURE 9

dataDE <- data4[ which(data4$Country=='Deutschland'), ]

dataDE$Share10 <- ifelse(dataDE$Conjoint.Share == "10 Prozent Frauen, 90 Prozent MÃ¤nner", 1,0)
dataDE$Share20 <- ifelse(dataDE$Conjoint.Share == "20 Prozent Frauen, 80 Prozent MÃ¤nner", 1,0)
dataDE$Share30 <- ifelse(dataDE$Conjoint.Share == "30 Prozent Frauen,  70 Prozent MÃ¤nner", 1,0)
dataDE$Share40 <- ifelse(dataDE$Conjoint.Share == "40 Prozent Frauen, 60 Prozent MÃ¤nner", 1,0)
dataDE$Share50 <- ifelse(dataDE$Conjoint.Share == "50 Prozent Frauen, 50 Prozent MÃ¤nner", 1,0)

mm.10R <- mm(dataDE[dataDE$Share10 == 1 & dataDE$Rough_Ideology == "Right Wing",], f1, id = ~ID,  alpha = 0.05)
mm.10C <- mm(dataDE[dataDE$Share10 == 1 & dataDE$Rough_Ideology == "Center",], f1, id = ~ID,  alpha = 0.05)
mm.10L <- mm(dataDE[dataDE$Share10 == 1 & dataDE$Rough_Ideology == "Left Wing",], f1, id = ~ID,  alpha = 0.05)


mm.20R <- mm(dataDE[dataDE$Share20 == 1 & dataDE$Rough_Ideology == "Right Wing",], f1, id = ~ID,  alpha = 0.05)
mm.20C <- mm(dataDE[dataDE$Share20 == 1 & dataDE$Rough_Ideology == "Center",], f1, id = ~ID,  alpha = 0.05)
mm.20L <- mm(dataDE[dataDE$Share20 == 1 & dataDE$Rough_Ideology == "Left Wing",], f1, id = ~ID,  alpha = 0.05)


mm.30R <- mm(dataDE[dataDE$Share30 == 1 & dataDE$Rough_Ideology == "Right Wing",], f1, id = ~ID,  alpha = 0.05)
mm.30C <- mm(dataDE[dataDE$Share30 == 1 & dataDE$Rough_Ideology == "Center",], f1, id = ~ID,  alpha = 0.05)
mm.30L <- mm(dataDE[dataDE$Share30 == 1 & dataDE$Rough_Ideology == "Left Wing",], f1, id = ~ID,  alpha = 0.05)


mm.40R <- mm(dataDE[dataDE$Share40 == 1 & dataDE$Rough_Ideology == "Right Wing",], f1, id = ~ID,  alpha = 0.05)
mm.40C <- mm(dataDE[dataDE$Share40 == 1 & dataDE$Rough_Ideology == "Center",], f1, id = ~ID,  alpha = 0.05)
mm.40L <- mm(dataDE[dataDE$Share40 == 1 & dataDE$Rough_Ideology == "Left Wing",], f1, id = ~ID,  alpha = 0.05)


mm.50R <- mm(dataDE[dataDE$Share50 == 1 & dataDE$Rough_Ideology == "Right Wing",], f1, id = ~ID,  alpha = 0.05)
mm.50C <- mm(dataDE[dataDE$Share50 == 1 & dataDE$Rough_Ideology == "Center",], f1, id = ~ID,  alpha = 0.05)
mm.50L <- mm(dataDE[dataDE$Share50 == 1 & dataDE$Rough_Ideology == "Left Wing",], f1, id = ~ID,  alpha = 0.05)


ggData <- data.frame(rbind(cbind(fold = "10% Women, 90% Men Right", mm.10R),
                           cbind(fold = "20% Women, 80% Men Right", mm.20R),
                           cbind(fold = "30% Women, 70% Men Right", mm.30R),
                           cbind(fold = "40% Women, 60% Men Right", mm.40R),
                           cbind(fold = "50% Women, 50% Men Right", mm.50R),
                           cbind(fold = "10% Women, 90% Men Center", mm.10C),
                           cbind(fold = "20% Women, 80% Men Center", mm.20C),
                           cbind(fold = "30% Women, 70% Men Center", mm.30C),
                           cbind(fold = "40% Women, 60% Men Center", mm.40C),
                           cbind(fold = "50% Women, 50% Men Center", mm.50C),
                           cbind(fold = "10% Women, 90% Men Left", mm.10L),
                           cbind(fold = "20% Women, 80% Men Left", mm.20L),
                           cbind(fold = "30% Women, 70% Men Left", mm.30L),
                           cbind(fold = "40% Women, 60% Men Left", mm.40L),
                           cbind(fold = "50% Women, 50% Men Left", mm.50L)))

ggData$Ideology <- NA
ggData$Ideology <- ifelse(ggData$fold == "10% Women, 90% Men Right", "Right Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "20% Women, 80% Men Right", "Right Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "30% Women, 70% Men Right", "Right Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "40% Women, 60% Men Right", "Right Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "50% Women, 50% Men Right", "Right Wing", ggData$Ideology)

ggData$Ideology <- ifelse(ggData$fold == "10% Women, 90% Men Center", "Center", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "20% Women, 80% Men Center", "Center", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "30% Women, 70% Men Center", "Center", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "40% Women, 60% Men Center", "Center", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "50% Women, 50% Men Center", "Center", ggData$Ideology)

ggData$Ideology <- ifelse(ggData$fold == "10% Women, 90% Men Left", "Left Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "20% Women, 80% Men Left", "Left Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "30% Women, 70% Men Left", "Left Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "40% Women, 60% Men Left", "Left Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "50% Women, 50% Men Left", "Left Wing", ggData$Ideology)
ggData$Ideology <- as.factor(ggData$Ideology)



ggData$Ideology <- factor(as.character(ggData$Ideology), 
                          levels = rev(c("Right Wing","Center","Left Wing"
                          )))

ggData$Share <- NA
ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Right", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Right", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Right", "30% Women, 70% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "40% Women, 60% Men Right", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Right", "50% Women, 50% Men", ggData$Share)

ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Center", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Center", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Center", "30% Women, 70% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "40% Women, 60% Men Center", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Center", "50% Women, 50% Men", ggData$Share)

ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Left", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Left", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Left", "30% Women, 70% Men", ggData$Share)
ggData$Share<- ifelse(ggData$fold == "40% Women, 60% Men Left", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Left", "50% Women, 50% Men", ggData$Share)
ggData$Share <- as.factor(ggData$Share)



ggData$level <- factor(as.character(ggData$level), 
                       levels = rev(c("Under 30","30-39","40-49", "50-59", "60 and Older",
                                      "Taxation", "Energy Policy", "Gender Equality", "Immigration",
                                      "Law & Order", "Welfare",
                                      "Local Council", "State Legislature", "National Legislature",
                                      "High School", "University Degree", "PhD", "Same Position",
                                      "More Leftwing", "More Rightwing",
                                      "Man", "Woman"
                       )))


ggData$stat_label <- NA
ggData$stat_label[ggData$statistic == "mm"] <- "MM"

ggData$hline <- NA
ggData$hline[ggData$statistic == "mm"] <- 0.5


ggData$feature2 <- NA
ggData$feature2[ggData$feature == "Conjoint.Age"] = "Age"
ggData$feature2[ggData$feature == "Conjoint.Gender"] = "Gender"
ggData$feature2[ggData$feature == "Conjoint.Experience"] = "Experience"
ggData$feature2[ggData$feature == "Conjoint.MIP"] = "Issue"
ggData$feature2[ggData$feature == "Conjoint.Education"] = "Education"
ggData$feature2[ggData$feature == "Conjoint.Ideology"] = "Ideology"


ggData$feature2 <- as.factor(ggData$feature2)
ggData$feature2 <- (factor(ggData$feature2, levels = c("Gender", "Age", "Education", "Experience", "Ideology","Issue")))

ggData[is.na(ggData$lower),"lower"] <- 0
ggData[is.na(ggData$upper),"upper"] <- 0

dodge <- position_dodge(width=-0.5)
p = ggplot(ggData[ ggData$feature  %in% c("Conjoint.Gender"),], aes(group=Ideology ))
p = p + geom_pointrange(aes(x = as.factor(level), y = estimate, ymin = lower, ymax = upper, shape=Ideology), position=dodge)
p = p + geom_hline(aes(yintercept = hline), linetype = 2)
p = p + facet_grid(Share ~ "Aspirant Gender", scales = "free_y") + xlab("") + ylab("Marginal Means")
p = p + scale_shape_discrete(labels = c("Left", "Center", "Right")) 
p = p +  labs(shape = "Respondent\nIdeology") 
p = p + coord_flip() + theme(axis.text = element_text(size = rel(0.8)),
                             axis.ticks = element_line(colour = "black"),
                             legend.key = element_rect(fill = "white"),
                             plot.margin = unit(c(0, 0, 0, 0), "cm"),
                             panel.background = element_rect(fill = "white", colour = NA),
                             panel.border = element_rect(fill = NA, colour = "grey50"),
                             panel.grid.major = element_line(colour = "grey90", size = 0.2),
                             panel.grid.minor = element_line(colour = "grey98", size = 0.5),
                             strip.background = element_rect(fill = "white", colour = "grey50"),
                             strip.text.x = element_text(size = 10, colour = "black", face = "bold"),
                             strip.text.y = element_text(size = 6, colour = "black", face = "bold"))   
p



### FIGURE 10

dataCH <- data4[ which(data4$Country=='Schweiz'), ]

dataCH$Share10 <- ifelse(dataCH$Conjoint.Share == "10 Prozent Frauen, 90 Prozent MÃ¤nner", 1,0)
dataCH$Share20 <- ifelse(dataCH$Conjoint.Share == "20 Prozent Frauen, 80 Prozent MÃ¤nner", 1,0)
dataCH$Share30 <- ifelse(dataCH$Conjoint.Share == "30 Prozent Frauen,  70 Prozent MÃ¤nner", 1,0)
dataCH$Share40 <- ifelse(dataCH$Conjoint.Share == "40 Prozent Frauen, 60 Prozent MÃ¤nner", 1,0)
dataCH$Share50 <- ifelse(dataCH$Conjoint.Share == "50 Prozent Frauen, 50 Prozent MÃ¤nner", 1,0)

mm.10R <- mm(dataCH[dataCH$Share10 == 1 & dataCH$Rough_Ideology == "Right Wing",], f1, id = ~ID,  alpha = 0.05)
mm.10C <- mm(dataCH[dataCH$Share10 == 1 & dataCH$Rough_Ideology == "Center",], f1, id = ~ID,  alpha = 0.05)
mm.10L <- mm(dataCH[dataCH$Share10 == 1 & dataCH$Rough_Ideology == "Left Wing",], f1, id = ~ID,  alpha = 0.05)


mm.20R <- mm(dataCH[dataCH$Share20 == 1 & dataCH$Rough_Ideology == "Right Wing",], f1, id = ~ID,  alpha = 0.05)
mm.20C <- mm(dataCH[dataCH$Share20 == 1 & dataCH$Rough_Ideology == "Center",], f1, id = ~ID,  alpha = 0.05)
mm.20L <- mm(dataCH[dataCH$Share20 == 1 & dataCH$Rough_Ideology == "Left Wing",], f1, id = ~ID,  alpha = 0.05)


mm.30R <- mm(dataCH[dataCH$Share30 == 1 & dataCH$Rough_Ideology == "Right Wing",], f1, id = ~ID,  alpha = 0.05)
mm.30C <- mm(dataCH[dataCH$Share30 == 1 & dataCH$Rough_Ideology == "Center",], f1, id = ~ID,  alpha = 0.05)
mm.30L <- mm(dataCH[dataCH$Share30 == 1 & dataCH$Rough_Ideology == "Left Wing",], f1, id = ~ID,  alpha = 0.05)


mm.40R <- mm(dataCH[dataCH$Share40 == 1 & dataCH$Rough_Ideology == "Right Wing",], f1, id = ~ID,  alpha = 0.05)
mm.40C <- mm(dataCH[dataCH$Share40 == 1 & dataCH$Rough_Ideology == "Center",], f1, id = ~ID,  alpha = 0.05)
mm.40L <- mm(dataCH[dataCH$Share40 == 1 & dataCH$Rough_Ideology == "Left Wing",], f1, id = ~ID,  alpha = 0.05)


mm.50R <- mm(dataCH[dataCH$Share50 == 1 & dataCH$Rough_Ideology == "Right Wing",], f1, id = ~ID,  alpha = 0.05)
mm.50C <- mm(dataCH[dataCH$Share50 == 1 & dataCH$Rough_Ideology == "Center",], f1, id = ~ID,  alpha = 0.05)
mm.50L <- mm(dataCH[dataCH$Share50 == 1 & dataCH$Rough_Ideology == "Left Wing",], f1, id = ~ID,  alpha = 0.05)


ggData <- data.frame(rbind(cbind(fold = "10% Women, 90% Men Right", mm.10R),
                           cbind(fold = "20% Women, 80% Men Right", mm.20R),
                           cbind(fold = "30% Women, 70% Men Right", mm.30R),
                           cbind(fold = "40% Women, 60% Men Right", mm.40R),
                           cbind(fold = "50% Women, 50% Men Right", mm.50R),
                           cbind(fold = "10% Women, 90% Men Center", mm.10C),
                           cbind(fold = "20% Women, 80% Men Center", mm.20C),
                           cbind(fold = "30% Women, 70% Men Center", mm.30C),
                           cbind(fold = "40% Women, 60% Men Center", mm.40C),
                           cbind(fold = "50% Women, 50% Men Center", mm.50C),
                           cbind(fold = "10% Women, 90% Men Left", mm.10L),
                           cbind(fold = "20% Women, 80% Men Left", mm.20L),
                           cbind(fold = "30% Women, 70% Men Left", mm.30L),
                           cbind(fold = "40% Women, 60% Men Left", mm.40L),
                           cbind(fold = "50% Women, 50% Men Left", mm.50L)))

ggData$Ideology <- NA
ggData$Ideology <- ifelse(ggData$fold == "10% Women, 90% Men Right", "Right Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "20% Women, 80% Men Right", "Right Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "30% Women, 70% Men Right", "Right Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "40% Women, 60% Men Right", "Right Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "50% Women, 50% Men Right", "Right Wing", ggData$Ideology)

ggData$Ideology <- ifelse(ggData$fold == "10% Women, 90% Men Center", "Center", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "20% Women, 80% Men Center", "Center", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "30% Women, 70% Men Center", "Center", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "40% Women, 60% Men Center", "Center", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "50% Women, 50% Men Center", "Center", ggData$Ideology)

ggData$Ideology <- ifelse(ggData$fold == "10% Women, 90% Men Left", "Left Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "20% Women, 80% Men Left", "Left Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "30% Women, 70% Men Left", "Left Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "40% Women, 60% Men Left", "Left Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "50% Women, 50% Men Left", "Left Wing", ggData$Ideology)
ggData$Ideology <- as.factor(ggData$Ideology)


ggData$Ideology <- factor(as.character(ggData$Ideology), 
                          levels = rev(c("Right Wing", "Center", "Left Wing"
                          )))


ggData$Share <- NA
ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Right", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Right", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Right", "30% Women, 70% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "40% Women, 60% Men Right", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Right", "50% Women, 50% Men", ggData$Share)

ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Center", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Center", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Center", "30% Women, 70% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "40% Women, 60% Men Center", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Center", "50% Women, 50% Men", ggData$Share)

ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Left", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Left", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Left", "30% Women, 70% Men", ggData$Share)
ggData$Share<- ifelse(ggData$fold == "40% Women, 60% Men Left", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Left", "50% Women, 50% Men", ggData$Share)
ggData$Share <- as.factor(ggData$Share)



ggData$level <- factor(as.character(ggData$level), 
                       levels = rev(c("Under 30","30-39","40-49", "50-59", "60 and Older",
                                      "Taxation", "Energy Policy", "Gender Equality", "Immigration",
                                      "Law & Order", "Welfare",
                                      "Local Council", "State Legislature", "National Legislature",
                                      "High School", "University Degree", "PhD", "Same Position",
                                      "More Leftwing", "More Rightwing",
                                      "Man", "Woman"
                       )))


ggData$stat_label <- NA
ggData$stat_label[ggData$statistic == "mm"] <- "MM"

ggData$hline <- NA
ggData$hline[ggData$statistic == "mm"] <- 0.5


ggData$feature2 <- NA
ggData$feature2[ggData$feature == "Conjoint.Age"] = "Age"
ggData$feature2[ggData$feature == "Conjoint.Gender"] = "Gender"
ggData$feature2[ggData$feature == "Conjoint.Experience"] = "Experience"
ggData$feature2[ggData$feature == "Conjoint.MIP"] = "Issue"
ggData$feature2[ggData$feature == "Conjoint.Education"] = "Education"
ggData$feature2[ggData$feature == "Conjoint.Ideology"] = "Ideology"


ggData$feature2 <- as.factor(ggData$feature2)
ggData$feature2 <- (factor(ggData$feature2, levels = c("Gender", "Age", "Education", "Experience", "Ideology","Issue")))

ggData[is.na(ggData$lower),"lower"] <- 0
ggData[is.na(ggData$upper),"upper"] <- 0

dodge <- position_dodge(width=-0.5)
p = ggplot(ggData[ ggData$feature  %in% c("Conjoint.Gender"),], aes(group=Ideology ))
p = p + geom_pointrange(aes(x = as.factor(level), y = estimate, ymin = lower, ymax = upper, shape=Ideology), position=dodge)
p = p + geom_hline(aes(yintercept = hline), linetype = 2)
p = p + facet_grid(Share ~ "Aspirant Gender", scales = "free_y") + xlab("") + ylab("Marginal Means")
p = p + scale_shape_discrete(labels = c("Left", "Center", "Right")) 
p = p +  labs(shape = "Respondent\nIdeology") 
p = p + coord_flip() + theme(axis.text = element_text(size = rel(0.8)),
                             axis.ticks = element_line(colour = "black"),
                             legend.key = element_rect(fill = "white"),
                             plot.margin = unit(c(0, 0, 0, 0), "cm"),
                             panel.background = element_rect(fill = "white", colour = NA),
                             panel.border = element_rect(fill = NA, colour = "grey50"),
                             panel.grid.major = element_line(colour = "grey90", size = 0.2),
                             panel.grid.minor = element_line(colour = "grey98", size = 0.5),
                             strip.background = element_rect(fill = "white", colour = "grey50"),
                             strip.text.x = element_text(size = 10, colour = "black", face = "bold"),
                             strip.text.y = element_text(size = 6, colour = "black", face = "bold"))   
p



### FIGURE 11

dataQuota <- data4[ which(data4$Quota=='Yes'), ]

dataQuota$Share10 <- ifelse(dataQuota$Conjoint.Share == "10 Prozent Frauen, 90 Prozent MÃ¤nner", 1,0)
dataQuota$Share20 <- ifelse(dataQuota$Conjoint.Share == "20 Prozent Frauen, 80 Prozent MÃ¤nner", 1,0)
dataQuota$Share30 <- ifelse(dataQuota$Conjoint.Share == "30 Prozent Frauen,  70 Prozent MÃ¤nner", 1,0)
dataQuota$Share40 <- ifelse(dataQuota$Conjoint.Share == "40 Prozent Frauen, 60 Prozent MÃ¤nner", 1,0)
dataQuota$Share50 <- ifelse(dataQuota$Conjoint.Share == "50 Prozent Frauen, 50 Prozent MÃ¤nner", 1,0)

mm.10R <- mm(dataQuota[dataQuota$Share10 == 1 & dataQuota$Rough_Ideology == "Right Wing",], f1, id = ~ID,  alpha = 0.05)
mm.10C <- mm(dataQuota[dataQuota$Share10 == 1 & dataQuota$Rough_Ideology == "Center",], f1, id = ~ID,  alpha = 0.05)
mm.10L <- mm(dataQuota[dataQuota$Share10 == 1 & dataQuota$Rough_Ideology == "Left Wing",], f1, id = ~ID,  alpha = 0.05)


mm.20R <- mm(dataQuota[dataQuota$Share20 == 1 & dataQuota$Rough_Ideology == "Right Wing",], f1, id = ~ID,  alpha = 0.05)
mm.20C <- mm(dataQuota[dataQuota$Share20 == 1 & dataQuota$Rough_Ideology == "Center",], f1, id = ~ID,  alpha = 0.05)
mm.20L <- mm(dataQuota[dataQuota$Share20 == 1 & dataQuota$Rough_Ideology == "Left Wing",], f1, id = ~ID,  alpha = 0.05)


mm.30R <- mm(dataQuota[dataQuota$Share30 == 1 & dataQuota$Rough_Ideology == "Right Wing",], f1, id = ~ID,  alpha = 0.05)
mm.30C <- mm(dataQuota[dataQuota$Share30 == 1 & dataQuota$Rough_Ideology == "Center",], f1, id = ~ID,  alpha = 0.05)
mm.30L <- mm(dataQuota[dataQuota$Share30 == 1 & dataQuota$Rough_Ideology == "Left Wing",], f1, id = ~ID,  alpha = 0.05)


mm.40R <- mm(dataQuota[dataQuota$Share40 == 1 & dataQuota$Rough_Ideology == "Right Wing",], f1, id = ~ID,  alpha = 0.05)
mm.40C <- mm(dataQuota[dataQuota$Share40 == 1 & dataQuota$Rough_Ideology == "Center",], f1, id = ~ID,  alpha = 0.05)
mm.40L <- mm(dataQuota[dataQuota$Share40 == 1 & dataQuota$Rough_Ideology == "Left Wing",], f1, id = ~ID,  alpha = 0.05)


mm.50R <- mm(dataQuota[dataQuota$Share50 == 1 & dataQuota$Rough_Ideology == "Right Wing",], f1, id = ~ID,  alpha = 0.05)
mm.50C <- mm(dataQuota[dataQuota$Share50 == 1 & dataQuota$Rough_Ideology == "Center",], f1, id = ~ID,  alpha = 0.05)
mm.50L <- mm(dataQuota[dataQuota$Share50 == 1 & dataQuota$Rough_Ideology == "Left Wing",], f1, id = ~ID,  alpha = 0.05)


ggData <- data.frame(rbind(cbind(fold = "10% Women, 90% Men Center", mm.10C),
                           cbind(fold = "20% Women, 80% Men Center", mm.20C),
                           cbind(fold = "30% Women, 70% Men Center", mm.30C),
                           cbind(fold = "40% Women, 60% Men Center", mm.40C),
                           cbind(fold = "50% Women, 50% Men Center", mm.50C),
                           cbind(fold = "10% Women, 90% Men Left", mm.10L),
                           cbind(fold = "20% Women, 80% Men Left", mm.20L),
                           cbind(fold = "30% Women, 70% Men Left", mm.30L),
                           cbind(fold = "40% Women, 60% Men Left", mm.40L),
                           cbind(fold = "50% Women, 50% Men Left", mm.50L)))

ggData$Ideology <- NA
ggData$Ideology <- ifelse(ggData$fold == "10% Women, 90% Men Center", "Center", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "20% Women, 80% Men Center", "Center", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "30% Women, 70% Men Center", "Center", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "40% Women, 60% Men Center", "Center", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "50% Women, 50% Men Center", "Center", ggData$Ideology)

ggData$Ideology <- ifelse(ggData$fold == "10% Women, 90% Men Left", "Left Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "20% Women, 80% Men Left", "Left Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "30% Women, 70% Men Left", "Left Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "40% Women, 60% Men Left", "Left Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "50% Women, 50% Men Left", "Left Wing", ggData$Ideology)


ggData$Ideology <- factor(as.character(ggData$Ideology), 
                          levels = rev(c("Right Wing",  "Center","Left Wing"
                          )))
ggData$Ideology <- as.factor(ggData$Ideology)

ggData$Share <- NA
ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Center", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Center", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Center", "30% Women, 70% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "40% Women, 60% Men Center", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Center", "50% Women, 50% Men", ggData$Share)

ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Left", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Left", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Left", "30% Women, 70% Men", ggData$Share)
ggData$Share<- ifelse(ggData$fold == "40% Women, 60% Men Left", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Left", "50% Women, 50% Men", ggData$Share)
ggData$Share <- as.factor(ggData$Share)



ggData$level <- factor(as.character(ggData$level), 
                       levels = rev(c("Under 30","30-39","40-49", "50-59", "60 and Older",
                                      "Taxation", "Energy Policy", "Gender Equality", "Immigration",
                                      "Law & Order", "Welfare",
                                      "Local Council", "State Legislature", "National Legislature",
                                      "High School", "University Degree", "PhD", "Same Position",
                                      "More Leftwing", "More Rightwing",
                                      "Man", "Woman"
                       )))


ggData$stat_label <- NA
ggData$stat_label[ggData$statistic == "mm"] <- "MM"

ggData$hline <- NA
ggData$hline[ggData$statistic == "mm"] <- 0.5


ggData$feature2 <- NA
ggData$feature2[ggData$feature == "Conjoint.Age"] = "Age"
ggData$feature2[ggData$feature == "Conjoint.Gender"] = "Gender"
ggData$feature2[ggData$feature == "Conjoint.Experience"] = "Experience"
ggData$feature2[ggData$feature == "Conjoint.MIP"] = "Issue"
ggData$feature2[ggData$feature == "Conjoint.Education"] = "Education"
ggData$feature2[ggData$feature == "Conjoint.Ideology"] = "Ideology"


ggData$feature2 <- as.factor(ggData$feature2)
ggData$feature2 <- (factor(ggData$feature2, levels = c("Gender", "Age", "Education", "Experience", "Ideology","Issue")))

ggData[is.na(ggData$lower),"lower"] <- 0
ggData[is.na(ggData$upper),"upper"] <- 0


dodge <- position_dodge(width=-0.5)
p = ggplot(ggData[ ggData$feature  %in% c("Conjoint.Gender"),], aes(group=Ideology ))
p = p + geom_pointrange(aes(x = as.factor(level), y = estimate, ymin = lower, ymax = upper, shape=Ideology), position=dodge)
p = p + geom_hline(aes(yintercept = hline), linetype = 2)
p = p + facet_grid(Share ~ "Aspirant Gender", scales = "free_y") + xlab("") + ylab("Marginal Means")
p = p + scale_shape_discrete(labels = c("Left", "Center", "Right")) 
p = p +  labs(shape = "Respondent\nIdeology") 
p = p + coord_flip() + theme(axis.text = element_text(size = rel(0.8)),
                             axis.ticks = element_line(colour = "black"),
                             legend.key = element_rect(fill = "white"),
                             plot.margin = unit(c(0, 0, 0, 0), "cm"),
                             panel.background = element_rect(fill = "white", colour = NA),
                             panel.border = element_rect(fill = NA, colour = "grey50"),
                             panel.grid.major = element_line(colour = "grey90", size = 0.2),
                             panel.grid.minor = element_line(colour = "grey98", size = 0.5),
                             strip.background = element_rect(fill = "white", colour = "grey50"),
                             strip.text.x = element_text(size = 10, colour = "black", face = "bold"),
                             strip.text.y = element_text(size = 6, colour = "black", face = "bold"))   
p



### FIGURE 12

dataNoQuota <- data4[ which(data4$Quota=='No'), ]


dataNoQuota$Share10 <- ifelse(dataNoQuota$Conjoint.Share == "10 Prozent Frauen, 90 Prozent MÃ¤nner", 1,0)
dataNoQuota$Share20 <- ifelse(dataNoQuota$Conjoint.Share == "20 Prozent Frauen, 80 Prozent MÃ¤nner", 1,0)
dataNoQuota$Share30 <- ifelse(dataNoQuota$Conjoint.Share == "30 Prozent Frauen,  70 Prozent MÃ¤nner", 1,0)
dataNoQuota$Share40 <- ifelse(dataNoQuota$Conjoint.Share == "40 Prozent Frauen, 60 Prozent MÃ¤nner", 1,0)
dataNoQuota$Share50 <- ifelse(dataNoQuota$Conjoint.Share == "50 Prozent Frauen, 50 Prozent MÃ¤nner", 1,0)

mm.10R <- mm(dataNoQuota[dataNoQuota$Share10 == 1 & dataNoQuota$Rough_Ideology == "Right Wing",], f1, id = ~ID,  alpha = 0.05)
mm.10C <- mm(dataNoQuota[dataNoQuota$Share10 == 1 & dataNoQuota$Rough_Ideology == "Center",], f1, id = ~ID,  alpha = 0.05)
mm.10L <- mm(dataNoQuota[dataNoQuota$Share10 == 1 & dataNoQuota$Rough_Ideology == "Left Wing",], f1, id = ~ID,  alpha = 0.05)


mm.20R <- mm(dataNoQuota[dataNoQuota$Share20 == 1 & dataNoQuota$Rough_Ideology == "Right Wing",], f1, id = ~ID,  alpha = 0.05)
mm.20C <- mm(dataNoQuota[dataNoQuota$Share20 == 1 & dataNoQuota$Rough_Ideology == "Center",], f1, id = ~ID,  alpha = 0.05)
mm.20L <- mm(dataNoQuota[dataNoQuota$Share20 == 1 & dataNoQuota$Rough_Ideology == "Left Wing",], f1, id = ~ID,  alpha = 0.05)


mm.30R <- mm(dataNoQuota[dataNoQuota$Share30 == 1 & dataNoQuota$Rough_Ideology == "Right Wing",], f1, id = ~ID,  alpha = 0.05)
mm.30C <- mm(dataNoQuota[dataNoQuota$Share30 == 1 & dataNoQuota$Rough_Ideology == "Center",], f1, id = ~ID,  alpha = 0.05)
mm.30L <- mm(dataNoQuota[dataNoQuota$Share30 == 1 & dataNoQuota$Rough_Ideology == "Left Wing",], f1, id = ~ID,  alpha = 0.05)


mm.40R <- mm(dataNoQuota[dataNoQuota$Share40 == 1 & dataNoQuota$Rough_Ideology == "Right Wing",], f1, id = ~ID,  alpha = 0.05)
mm.40C <- mm(dataNoQuota[dataNoQuota$Share40 == 1 & dataNoQuota$Rough_Ideology == "Center",], f1, id = ~ID,  alpha = 0.05)
mm.40L <- mm(dataNoQuota[dataNoQuota$Share40 == 1 & dataNoQuota$Rough_Ideology == "Left Wing",], f1, id = ~ID,  alpha = 0.05)


mm.50R <- mm(dataNoQuota[dataNoQuota$Share50 == 1 & dataNoQuota$Rough_Ideology == "Right Wing",], f1, id = ~ID,  alpha = 0.05)
mm.50C <- mm(dataNoQuota[dataNoQuota$Share50 == 1 & dataNoQuota$Rough_Ideology == "Center",], f1, id = ~ID,  alpha = 0.05)
mm.50L <- mm(dataNoQuota[dataNoQuota$Share50 == 1 & dataNoQuota$Rough_Ideology == "Left Wing",], f1, id = ~ID,  alpha = 0.05)


ggData <- data.frame(rbind(cbind(fold = "10% Women, 90% Men Right", mm.10R),
                           cbind(fold = "20% Women, 80% Men Right", mm.20R),
                           cbind(fold = "30% Women, 70% Men Right", mm.30R),
                           cbind(fold = "40% Women, 60% Men Right", mm.40R),
                           cbind(fold = "50% Women, 50% Men Right", mm.50R),
                           cbind(fold = "10% Women, 90% Men Center", mm.10C),
                           cbind(fold = "20% Women, 80% Men Center", mm.20C),
                           cbind(fold = "30% Women, 70% Men Center", mm.30C),
                           cbind(fold = "40% Women, 60% Men Center", mm.40C),
                           cbind(fold = "50% Women, 50% Men Center", mm.50C),
                           cbind(fold = "10% Women, 90% Men Left", mm.10L),
                           cbind(fold = "20% Women, 80% Men Left", mm.20L),
                           cbind(fold = "30% Women, 70% Men Left", mm.30L),
                           cbind(fold = "40% Women, 60% Men Left", mm.40L),
                           cbind(fold = "50% Women, 50% Men Left", mm.50L)))

ggData$Ideology <- NA
ggData$Ideology <- ifelse(ggData$fold == "10% Women, 90% Men Right", "Right Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "20% Women, 80% Men Right", "Right Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "30% Women, 70% Men Right", "Right Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "40% Women, 60% Men Right", "Right Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "50% Women, 50% Men Right", "Right Wing", ggData$Ideology)

ggData$Ideology <- ifelse(ggData$fold == "10% Women, 90% Men Center", "Center", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "20% Women, 80% Men Center", "Center", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "30% Women, 70% Men Center", "Center", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "40% Women, 60% Men Center", "Center", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "50% Women, 50% Men Center", "Center", ggData$Ideology)

ggData$Ideology <- ifelse(ggData$fold == "10% Women, 90% Men Left", "Left Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "20% Women, 80% Men Left", "Left Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "30% Women, 70% Men Left", "Left Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "40% Women, 60% Men Left", "Left Wing", ggData$Ideology)
ggData$Ideology <- ifelse(ggData$fold == "50% Women, 50% Men Left", "Left Wing", ggData$Ideology)
ggData$Ideology <- as.factor(ggData$Ideology)


ggData$Ideology <- factor(as.character(ggData$Ideology), 
                          levels = rev(c("Left Wing","Center","Right Wing"
                          )))

ggData$Share <- NA
ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Right", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Right", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Right", "30% Women, 70% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "40% Women, 60% Men Right", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Right", "50% Women, 50% Men", ggData$Share)

ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Center", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Center", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Center", "30% Women, 70% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "40% Women, 60% Men Center", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Center", "50% Women, 50% Men", ggData$Share)

ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Left", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Left", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Left", "30% Women, 70% Men", ggData$Share)
ggData$Share<- ifelse(ggData$fold == "40% Women, 60% Men Left", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Left", "50% Women, 50% Men", ggData$Share)
ggData$Share <- as.factor(ggData$Share)


ggData$Ideology <- factor(as.character(ggData$Ideology), 
                          levels = rev(c("Right Wing","Center","Left Wing"
                          )))

ggData$level <- factor(as.character(ggData$level), 
                       levels = rev(c("Under 30","30-39","40-49", "50-59", "60 and Older",
                                      "Taxation", "Energy Policy", "Gender Equality", "Immigration",
                                      "Law & Order", "Welfare",
                                      "Local Council", "State Legislature", "National Legislature",
                                      "High School", "University Degree", "PhD", "Same Position",
                                      "More Leftwing", "More Rightwing",
                                      "Man", "Woman"
                       )))


ggData$stat_label <- NA
ggData$stat_label[ggData$statistic == "mm"] <- "MM"

ggData$hline <- NA
ggData$hline[ggData$statistic == "mm"] <- 0.5


ggData$feature2 <- NA
ggData$feature2[ggData$feature == "Conjoint.Age"] = "Age"
ggData$feature2[ggData$feature == "Conjoint.Gender"] = "Gender"
ggData$feature2[ggData$feature == "Conjoint.Experience"] = "Experience"
ggData$feature2[ggData$feature == "Conjoint.MIP"] = "Issue"
ggData$feature2[ggData$feature == "Conjoint.Education"] = "Education"
ggData$feature2[ggData$feature == "Conjoint.Ideology"] = "Ideology"


ggData$feature2 <- as.factor(ggData$feature2)
ggData$feature2 <- (factor(ggData$feature2, levels = c("Gender", "Age", "Education", "Experience", "Ideology","Issue")))

ggData[is.na(ggData$lower),"lower"] <- 0
ggData[is.na(ggData$upper),"upper"] <- 0



dodge <- position_dodge(width=-0.5)
p = ggplot(ggData[ ggData$feature  %in% c("Conjoint.Gender"),], aes(group=Ideology ))
p = p + geom_pointrange(aes(x = as.factor(level), y = estimate, ymin = lower, ymax = upper, shape=Ideology), position=dodge)
p = p + geom_hline(aes(yintercept = hline), linetype = 2)
p = p + facet_grid(Share ~ "Aspirant Gender", scales = "free_y") + xlab("") + ylab("Marginal Means")
p = p + scale_shape_discrete(labels = c("Left", "Center", "Right")) 
p = p +  labs(shape = "Respondent\nIdeology") 
p = p + coord_flip() + theme(axis.text = element_text(size = rel(0.8)),
                             axis.ticks = element_line(colour = "black"),
                             legend.key = element_rect(fill = "white"),
                             plot.margin = unit(c(0, 0, 0, 0), "cm"),
                             panel.background = element_rect(fill = "white", colour = NA),
                             panel.border = element_rect(fill = NA, colour = "grey50"),
                             panel.grid.major = element_line(colour = "grey90", size = 0.2),
                             panel.grid.minor = element_line(colour = "grey98", size = 0.5),
                             strip.background = element_rect(fill = "white", colour = "grey50"),
                             strip.text.x = element_text(size = 10, colour = "black", face = "bold"),
                             strip.text.y = element_text(size = 6, colour = "black", face = "bold"))   
p


### FIGURE 13

dataAT$Share10 <- ifelse(dataAT$Conjoint.Share == "10 Prozent Frauen, 90 Prozent MÃ¤nner", 1,0)
dataAT$Share20 <- ifelse(dataAT$Conjoint.Share == "20 Prozent Frauen, 80 Prozent MÃ¤nner", 1,0)
dataAT$Share30 <- ifelse(dataAT$Conjoint.Share == "30 Prozent Frauen,  70 Prozent MÃ¤nner", 1,0)
dataAT$Share40 <- ifelse(dataAT$Conjoint.Share == "40 Prozent Frauen, 60 Prozent MÃ¤nner", 1,0)
dataAT$Share50 <- ifelse(dataAT$Conjoint.Share == "50 Prozent Frauen, 50 Prozent MÃ¤nner", 1,0)

mm.10M <- mm(dataAT[dataAT$Share10 == 1 & dataAT$Gender == "Man",], f1, id = ~ID,  alpha = 0.05)
mm.10W <- mm(dataAT[dataAT$Share10 == 1 & dataAT$Gender == "Woman",], f1, id = ~ID,  alpha = 0.05)

mm.20M <- mm(dataAT[dataAT$Share20 == 1 & dataAT$Gender == "Man",], f1, id = ~ID,  alpha = 0.05)
mm.20W <- mm(dataAT[dataAT$Share20 == 1 & dataAT$Gender == "Woman",], f1, id = ~ID,  alpha = 0.05)

mm.30M <- mm(dataAT[dataAT$Share30 == 1 & dataAT$Gender == "Man",], f1, id = ~ID,  alpha = 0.05)
mm.30W <- mm(dataAT[dataAT$Share30 == 1 & dataAT$Gender == "Woman",], f1, id = ~ID,  alpha = 0.05)

mm.40M <- mm(dataAT[dataAT$Share40 == 1 & dataAT$Gender == "Man",], f1, id = ~ID,  alpha = 0.05)
mm.40W <- mm(dataAT[dataAT$Share40 == 1 & dataAT$Gender == "Woman",], f1, id = ~ID,  alpha = 0.05)

mm.50M <- mm(dataAT[dataAT$Share50 == 1 & dataAT$Gender == "Man",], f1, id = ~ID,  alpha = 0.05)
mm.50W <- mm(dataAT[dataAT$Share50 == 1 & dataAT$Gender == "Woman",], f1, id = ~ID,  alpha = 0.05)

ggData <- data.frame(rbind(cbind(fold = "10% Women, 90% Men Men", mm.10M),
                           cbind(fold = "20% Women, 80% Men Men", mm.20M),
                           cbind(fold = "30% Women, 70% Men Men", mm.30M),
                           cbind(fold = "40% Women, 60% Men Men", mm.40M),
                           cbind(fold = "50% Women, 50% Men Men", mm.50M),
                           cbind(fold = "10% Women, 90% Men Women", mm.10W),
                           cbind(fold = "20% Women, 80% Men Women", mm.20W),
                           cbind(fold = "30% Women, 70% Men Women", mm.30W),
                           cbind(fold = "40% Women, 60% Men Women", mm.40W),
                           cbind(fold = "50% Women, 50% Men Women", mm.50W)))


ggData$Gender <- NA
ggData$Gender <- ifelse(ggData$fold == "10% Women, 90% Men Women", "Woman", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "20% Women, 80% Men Women", "Woman", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "30% Women, 70% Men Women", "Woman", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "40% Women, 60% Men Women", "Woman", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "50% Women, 50% Men Women", "Woman", ggData$Gender)

ggData$Gender <- ifelse(ggData$fold == "10% Women, 90% Men Men", "Man", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "20% Women, 80% Men Men", "Man", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "30% Women, 70% Men Men", "Man", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "40% Women, 60% Men Men", "Man", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "50% Women, 50% Men Men", "Man", ggData$Gender)

ggData$Share <- NA
ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Women", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Women", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Women", "30% Women, 70% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "40% Women, 60% Men Women", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Women", "50% Women, 50% Men", ggData$Share)

ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Men", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Men", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Men", "30% Women, 70% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "40% Women, 60% Men Men", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Men", "50% Women, 50% Men", ggData$Share)




ggData$level <- factor(as.character(ggData$level), 
                       levels = rev(c("Under 30","30-39","40-49", "50-59", "60 and Older",
                                      "Taxation", "Energy Policy", "Gender Equality", "Immigration",
                                      "Law & Order", "Welfare",
                                      "Local Council", "State Legislature", "National Legislature",
                                      "High School", "University Degree", "PhD", "Same Position",
                                      "More Leftwing", "More Rightwing",
                                      "Man", "Woman"
                       )))


ggData$stat_label <- NA
ggData$stat_label[ggData$statistic == "mm"] <- "MM"

ggData$hline <- NA
ggData$hline[ggData$statistic == "mm"] <- 0.5


ggData$feature2 <- NA
ggData$feature2[ggData$feature == "Conjoint.Age"] = "Age"
ggData$feature2[ggData$feature == "Conjoint.Gender"] = "Gender"
ggData$feature2[ggData$feature == "Conjoint.Experience"] = "Experience"
ggData$feature2[ggData$feature == "Conjoint.MIP"] = "Issue"
ggData$feature2[ggData$feature == "Conjoint.Education"] = "Education"
ggData$feature2[ggData$feature == "Conjoint.Ideology"] = "Ideology"


ggData$feature2 <- as.factor(ggData$feature2)
ggData$feature2 <- (factor(ggData$feature2, levels = c("Gender", "Age", "Education", "Experience", "Ideology","Issue")))

ggData[is.na(ggData$lower),"lower"] <- 0
ggData[is.na(ggData$upper),"upper"] <- 0

dodge <- position_dodge(width=-0.5)
p = ggplot(ggData[ ggData$feature  %in% c("Conjoint.Gender"),], aes(group=Gender ))
p = p + geom_pointrange(aes(x = as.factor(level), y = estimate, ymin = lower, ymax = upper, shape=Gender), position=dodge)
p = p + geom_hline(aes(yintercept = hline), linetype = 2)
p = p + facet_grid(Share ~ "Aspirant Gender", scales = "free_y") + xlab("") + ylab("Marginal Means")
p = p + scale_shape_discrete(labels = c("Man", "Woman")) 
p = p +  labs(shape = "Respondent\nGender") 
p = p + coord_flip() + theme(axis.text = element_text(size = rel(0.8)),
                             axis.ticks = element_line(colour = "black"),
                             legend.key = element_rect(fill = "white"),
                             plot.margin = unit(c(0, 0, 0, 0), "cm"),
                             panel.background = element_rect(fill = "white", colour = NA),
                             panel.border = element_rect(fill = NA, colour = "grey50"),
                             panel.grid.major = element_line(colour = "grey90", size = 0.2),
                             panel.grid.minor = element_line(colour = "grey98", size = 0.5),
                             strip.background = element_rect(fill = "white", colour = "grey50"),
                             strip.text.x = element_text(size = 10, colour = "black", face = "bold"),
                             strip.text.y = element_text(size = 6, colour = "black", face = "bold"))   
p


### FIGURE 14

dataDE$Share10 <- ifelse(dataDE$Conjoint.Share == "10 Prozent Frauen, 90 Prozent MÃ¤nner", 1,0)
dataDE$Share20 <- ifelse(dataDE$Conjoint.Share == "20 Prozent Frauen, 80 Prozent MÃ¤nner", 1,0)
dataDE$Share30 <- ifelse(dataDE$Conjoint.Share == "30 Prozent Frauen,  70 Prozent MÃ¤nner", 1,0)
dataDE$Share40 <- ifelse(dataDE$Conjoint.Share == "40 Prozent Frauen, 60 Prozent MÃ¤nner", 1,0)
dataDE$Share50 <- ifelse(dataDE$Conjoint.Share == "50 Prozent Frauen, 50 Prozent MÃ¤nner", 1,0)

mm.10M <- mm(dataDE[dataDE$Share10 == 1 & dataDE$Gender == "Man",], f1, id = ~ID,  alpha = 0.05)
mm.10W <- mm(dataDE[dataDE$Share10 == 1 & dataDE$Gender == "Woman",], f1, id = ~ID,  alpha = 0.05)

mm.20M <- mm(dataDE[dataDE$Share20 == 1 & dataDE$Gender == "Man",], f1, id = ~ID,  alpha = 0.05)
mm.20W <- mm(dataDE[dataDE$Share20 == 1 & dataDE$Gender == "Woman",], f1, id = ~ID,  alpha = 0.05)

mm.30M <- mm(dataDE[dataDE$Share30 == 1 & dataDE$Gender == "Man",], f1, id = ~ID,  alpha = 0.05)
mm.30W <- mm(dataDE[dataDE$Share30 == 1 & dataDE$Gender == "Woman",], f1, id = ~ID,  alpha = 0.05)

mm.40M <- mm(dataDE[dataDE$Share40 == 1 & dataDE$Gender == "Man",], f1, id = ~ID,  alpha = 0.05)
mm.40W <- mm(dataDE[dataDE$Share40 == 1 & dataDE$Gender == "Woman",], f1, id = ~ID,  alpha = 0.05)

mm.50M <- mm(dataDE[dataDE$Share50 == 1 & dataDE$Gender == "Man",], f1, id = ~ID,  alpha = 0.05)
mm.50W <- mm(dataDE[dataDE$Share50 == 1 & dataDE$Gender == "Woman",], f1, id = ~ID,  alpha = 0.05)

ggData <- data.frame(rbind(cbind(fold = "10% Women, 90% Men Men", mm.10M),
                           cbind(fold = "20% Women, 80% Men Men", mm.20M),
                           cbind(fold = "30% Women, 70% Men Men", mm.30M),
                           cbind(fold = "40% Women, 60% Men Men", mm.40M),
                           cbind(fold = "50% Women, 50% Men Men", mm.50M),
                           cbind(fold = "10% Women, 90% Men Women", mm.10W),
                           cbind(fold = "20% Women, 80% Men Women", mm.20W),
                           cbind(fold = "30% Women, 70% Men Women", mm.30W),
                           cbind(fold = "40% Women, 60% Men Women", mm.40W),
                           cbind(fold = "50% Women, 50% Men Women", mm.50W)))


ggData$Gender <- NA
ggData$Gender <- ifelse(ggData$fold == "10% Women, 90% Men Women", "Woman", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "20% Women, 80% Men Women", "Woman", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "30% Women, 70% Men Women", "Woman", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "40% Women, 60% Men Women", "Woman", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "50% Women, 50% Men Women", "Woman", ggData$Gender)

ggData$Gender <- ifelse(ggData$fold == "10% Women, 90% Men Men", "Man", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "20% Women, 80% Men Men", "Man", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "30% Women, 70% Men Men", "Man", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "40% Women, 60% Men Men", "Man", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "50% Women, 50% Men Men", "Man", ggData$Gender)

ggData$Share <- NA
ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Women", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Women", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Women", "30% Women, 70% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "40% Women, 60% Men Women", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Women", "50% Women, 50% Men", ggData$Share)

ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Men", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Men", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Men", "30% Women, 70% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "40% Women, 60% Men Men", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Men", "50% Women, 50% Men", ggData$Share)




ggData$level <- factor(as.character(ggData$level), 
                       levels = rev(c("Under 30","30-39","40-49", "50-59", "60 and Older",
                                      "Taxation", "Energy Policy", "Gender Equality", "Immigration",
                                      "Law & Order", "Welfare",
                                      "Local Council", "State Legislature", "National Legislature",
                                      "High School", "University Degree", "PhD", "Same Position",
                                      "More Leftwing", "More Rightwing",
                                      "Man", "Woman"
                       )))


ggData$stat_label <- NA
ggData$stat_label[ggData$statistic == "mm"] <- "MM"

ggData$hline <- NA
ggData$hline[ggData$statistic == "mm"] <- 0.5


ggData$feature2 <- NA
ggData$feature2[ggData$feature == "Conjoint.Age"] = "Age"
ggData$feature2[ggData$feature == "Conjoint.Gender"] = "Gender"
ggData$feature2[ggData$feature == "Conjoint.Experience"] = "Experience"
ggData$feature2[ggData$feature == "Conjoint.MIP"] = "Issue"
ggData$feature2[ggData$feature == "Conjoint.Education"] = "Education"
ggData$feature2[ggData$feature == "Conjoint.Ideology"] = "Ideology"


ggData$feature2 <- as.factor(ggData$feature2)
ggData$feature2 <- (factor(ggData$feature2, levels = c("Gender", "Age", "Education", "Experience", "Ideology","Issue")))

ggData[is.na(ggData$lower),"lower"] <- 0
ggData[is.na(ggData$upper),"upper"] <- 0


dodge <- position_dodge(width=-0.5)
p = ggplot(ggData[ ggData$feature  %in% c("Conjoint.Gender"),], aes(group=Gender ))
p = p + geom_pointrange(aes(x = as.factor(level), y = estimate, ymin = lower, ymax = upper, shape=Gender), position=dodge)
p = p + geom_hline(aes(yintercept = hline), linetype = 2)
p = p + facet_grid(Share ~ "Aspirant Gender", scales = "free_y") + xlab("") + ylab("Marginal Means")
p = p + scale_shape_discrete(labels = c("Man", "Woman")) 
p = p +  labs(shape = "Respondent\nGender") 
p = p + coord_flip() + theme(axis.text = element_text(size = rel(0.8)),
                             axis.ticks = element_line(colour = "black"),
                             legend.key = element_rect(fill = "white"),
                             plot.margin = unit(c(0, 0, 0, 0), "cm"),
                             panel.background = element_rect(fill = "white", colour = NA),
                             panel.border = element_rect(fill = NA, colour = "grey50"),
                             panel.grid.major = element_line(colour = "grey90", size = 0.2),
                             panel.grid.minor = element_line(colour = "grey98", size = 0.5),
                             strip.background = element_rect(fill = "white", colour = "grey50"),
                             strip.text.x = element_text(size = 10, colour = "black", face = "bold"),
                             strip.text.y = element_text(size = 6, colour = "black", face = "bold"))   
p



### FIGURE 15

dataCH$Share10 <- ifelse(dataCH$Conjoint.Share == "10 Prozent Frauen, 90 Prozent MÃ¤nner", 1,0)
dataCH$Share20 <- ifelse(dataCH$Conjoint.Share == "20 Prozent Frauen, 80 Prozent MÃ¤nner", 1,0)
dataCH$Share30 <- ifelse(dataCH$Conjoint.Share == "30 Prozent Frauen,  70 Prozent MÃ¤nner", 1,0)
dataCH$Share40 <- ifelse(dataCH$Conjoint.Share == "40 Prozent Frauen, 60 Prozent MÃ¤nner", 1,0)
dataCH$Share50 <- ifelse(dataCH$Conjoint.Share == "50 Prozent Frauen, 50 Prozent MÃ¤nner", 1,0)

mm.10M <- mm(dataCH[dataCH$Share10 == 1 & dataCH$Gender == "Man",], f1, id = ~ID,  alpha = 0.05)
mm.10W <- mm(dataCH[dataCH$Share10 == 1 & dataCH$Gender == "Woman",], f1, id = ~ID,  alpha = 0.05)

mm.20M <- mm(dataCH[dataCH$Share20 == 1 & dataCH$Gender == "Man",], f1, id = ~ID,  alpha = 0.05)
mm.20W <- mm(dataCH[dataCH$Share20 == 1 & dataCH$Gender == "Woman",], f1, id = ~ID,  alpha = 0.05)

mm.30M <- mm(dataCH[dataCH$Share30 == 1 & dataCH$Gender == "Man",], f1, id = ~ID,  alpha = 0.05)
mm.30W <- mm(dataCH[dataCH$Share30 == 1 & dataCH$Gender == "Woman",], f1, id = ~ID,  alpha = 0.05)

mm.40M <- mm(dataCH[dataCH$Share40 == 1 & dataCH$Gender == "Man",], f1, id = ~ID,  alpha = 0.05)
mm.40W <- mm(dataCH[dataCH$Share40 == 1 & dataCH$Gender == "Woman",], f1, id = ~ID,  alpha = 0.05)

mm.50M <- mm(dataCH[dataCH$Share50 == 1 & dataCH$Gender == "Man",], f1, id = ~ID,  alpha = 0.05)
mm.50W <- mm(dataCH[dataCH$Share50 == 1 & dataCH$Gender == "Woman",], f1, id = ~ID,  alpha = 0.05)

ggData <- data.frame(rbind(cbind(fold = "10% Women, 90% Men Men", mm.10M),
                           cbind(fold = "20% Women, 80% Men Men", mm.20M),
                           cbind(fold = "30% Women, 70% Men Men", mm.30M),
                           cbind(fold = "40% Women, 60% Men Men", mm.40M),
                           cbind(fold = "50% Women, 50% Men Men", mm.50M),
                           cbind(fold = "10% Women, 90% Men Women", mm.10W),
                           cbind(fold = "20% Women, 80% Men Women", mm.20W),
                           cbind(fold = "30% Women, 70% Men Women", mm.30W),
                           cbind(fold = "40% Women, 60% Men Women", mm.40W),
                           cbind(fold = "50% Women, 50% Men Women", mm.50W)))


ggData$Gender <- NA
ggData$Gender <- ifelse(ggData$fold == "10% Women, 90% Men Women", "Woman", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "20% Women, 80% Men Women", "Woman", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "30% Women, 70% Men Women", "Woman", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "40% Women, 60% Men Women", "Woman", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "50% Women, 50% Men Women", "Woman", ggData$Gender)

ggData$Gender <- ifelse(ggData$fold == "10% Women, 90% Men Men", "Man", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "20% Women, 80% Men Men", "Man", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "30% Women, 70% Men Men", "Man", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "40% Women, 60% Men Men", "Man", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "50% Women, 50% Men Men", "Man", ggData$Gender)

ggData$Share <- NA
ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Women", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Women", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Women", "30% Women, 70% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "40% Women, 60% Men Women", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Women", "50% Women, 50% Men", ggData$Share)

ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Men", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Men", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Men", "30% Women, 70% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "40% Women, 60% Men Men", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Men", "50% Women, 50% Men", ggData$Share)




ggData$level <- factor(as.character(ggData$level), 
                       levels = rev(c("Under 30","30-39","40-49", "50-59", "60 and Older",
                                      "Taxation", "Energy Policy", "Gender Equality", "Immigration",
                                      "Law & Order", "Welfare",
                                      "Local Council", "State Legislature", "National Legislature",
                                      "High School", "University Degree", "PhD", "Same Position",
                                      "More Leftwing", "More Rightwing",
                                      "Man", "Woman"
                       )))


ggData$stat_label <- NA
ggData$stat_label[ggData$statistic == "mm"] <- "MM"

ggData$hline <- NA
ggData$hline[ggData$statistic == "mm"] <- 0.5


ggData$feature2 <- NA
ggData$feature2[ggData$feature == "Conjoint.Age"] = "Age"
ggData$feature2[ggData$feature == "Conjoint.Gender"] = "Gender"
ggData$feature2[ggData$feature == "Conjoint.Experience"] = "Experience"
ggData$feature2[ggData$feature == "Conjoint.MIP"] = "Issue"
ggData$feature2[ggData$feature == "Conjoint.Education"] = "Education"
ggData$feature2[ggData$feature == "Conjoint.Ideology"] = "Ideology"


ggData$feature2 <- as.factor(ggData$feature2)
ggData$feature2 <- (factor(ggData$feature2, levels = c("Gender", "Age", "Education", "Experience", "Ideology","Issue")))

ggData[is.na(ggData$lower),"lower"] <- 0
ggData[is.na(ggData$upper),"upper"] <- 0

dodge <- position_dodge(width=-0.5)
p = ggplot(ggData[ ggData$feature  %in% c("Conjoint.Gender"),], aes(group=Gender ))
p = p + geom_pointrange(aes(x = as.factor(level), y = estimate, ymin = lower, ymax = upper, shape=Gender), position=dodge)
p = p + geom_hline(aes(yintercept = hline), linetype = 2)
p = p + facet_grid(Share ~ "Aspirant Gender", scales = "free_y") + xlab("") + ylab("Marginal Means")
p = p + scale_shape_discrete(labels = c("Man", "Woman")) 
p = p +  labs(shape = "Respondent\nGender") 
p = p + coord_flip() + theme(axis.text = element_text(size = rel(0.8)),
                             axis.ticks = element_line(colour = "black"),
                             legend.key = element_rect(fill = "white"),
                             plot.margin = unit(c(0, 0, 0, 0), "cm"),
                             panel.background = element_rect(fill = "white", colour = NA),
                             panel.border = element_rect(fill = NA, colour = "grey50"),
                             panel.grid.major = element_line(colour = "grey90", size = 0.2),
                             panel.grid.minor = element_line(colour = "grey98", size = 0.5),
                             strip.background = element_rect(fill = "white", colour = "grey50"),
                             strip.text.x = element_text(size = 10, colour = "black", face = "bold"),
                             strip.text.y = element_text(size = 6, colour = "black", face = "bold"))   
p




### FIGURE 16

dataQuota$Share10 <- ifelse(dataQuota$Conjoint.Share == "10 Prozent Frauen, 90 Prozent MÃ¤nner", 1,0)
dataQuota$Share20 <- ifelse(dataQuota$Conjoint.Share == "20 Prozent Frauen, 80 Prozent MÃ¤nner", 1,0)
dataQuota$Share30 <- ifelse(dataQuota$Conjoint.Share == "30 Prozent Frauen,  70 Prozent MÃ¤nner", 1,0)
dataQuota$Share40 <- ifelse(dataQuota$Conjoint.Share == "40 Prozent Frauen, 60 Prozent MÃ¤nner", 1,0)
dataQuota$Share50 <- ifelse(dataQuota$Conjoint.Share == "50 Prozent Frauen, 50 Prozent MÃ¤nner", 1,0)

mm.10M <- mm(dataQuota[dataQuota$Share10 == 1 & dataQuota$Gender == "Man",], f1, id = ~ID,  alpha = 0.05)
mm.10W <- mm(dataQuota[dataQuota$Share10 == 1 & dataQuota$Gender == "Woman",], f1, id = ~ID,  alpha = 0.05)

mm.20M <- mm(dataQuota[dataQuota$Share20 == 1 & dataQuota$Gender == "Man",], f1, id = ~ID,  alpha = 0.05)
mm.20W <- mm(dataQuota[dataQuota$Share20 == 1 & dataQuota$Gender == "Woman",], f1, id = ~ID,  alpha = 0.05)

mm.30M <- mm(dataQuota[dataQuota$Share30 == 1 & dataQuota$Gender == "Man",], f1, id = ~ID,  alpha = 0.05)
mm.30W <- mm(dataQuota[dataQuota$Share30 == 1 & dataQuota$Gender == "Woman",], f1, id = ~ID,  alpha = 0.05)

mm.40M <- mm(dataQuota[dataQuota$Share40 == 1 & dataQuota$Gender == "Man",], f1, id = ~ID,  alpha = 0.05)
mm.40W <- mm(dataQuota[dataQuota$Share40 == 1 & dataQuota$Gender == "Woman",], f1, id = ~ID,  alpha = 0.05)

mm.50M <- mm(dataQuota[dataQuota$Share50 == 1 & dataQuota$Gender == "Man",], f1, id = ~ID,  alpha = 0.05)
mm.50W <- mm(dataQuota[dataQuota$Share50 == 1 & dataQuota$Gender == "Woman",], f1, id = ~ID,  alpha = 0.05)

ggData <- data.frame(rbind(cbind(fold = "10% Women, 90% Men Men", mm.10M),
                           cbind(fold = "20% Women, 80% Men Men", mm.20M),
                           cbind(fold = "30% Women, 70% Men Men", mm.30M),
                           cbind(fold = "40% Women, 60% Men Men", mm.40M),
                           cbind(fold = "50% Women, 50% Men Men", mm.50M),
                           cbind(fold = "10% Women, 90% Men Women", mm.10W),
                           cbind(fold = "20% Women, 80% Men Women", mm.20W),
                           cbind(fold = "30% Women, 70% Men Women", mm.30W),
                           cbind(fold = "40% Women, 60% Men Women", mm.40W),
                           cbind(fold = "50% Women, 50% Men Women", mm.50W)))


ggData$Gender <- NA
ggData$Gender <- ifelse(ggData$fold == "10% Women, 90% Men Women", "Woman", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "20% Women, 80% Men Women", "Woman", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "30% Women, 70% Men Women", "Woman", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "40% Women, 60% Men Women", "Woman", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "50% Women, 50% Men Women", "Woman", ggData$Gender)

ggData$Gender <- ifelse(ggData$fold == "10% Women, 90% Men Men", "Man", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "20% Women, 80% Men Men", "Man", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "30% Women, 70% Men Men", "Man", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "40% Women, 60% Men Men", "Man", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "50% Women, 50% Men Men", "Man", ggData$Gender)

ggData$Share <- NA
ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Women", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Women", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Women", "30% Women, 70% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "40% Women, 60% Men Women", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Women", "50% Women, 50% Men", ggData$Share)

ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Men", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Men", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Men", "30% Women, 70% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "40% Women, 60% Men Men", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Men", "50% Women, 50% Men", ggData$Share)




ggData$level <- factor(as.character(ggData$level), 
                       levels = rev(c("Under 30","30-39","40-49", "50-59", "60 and Older",
                                      "Taxation", "Energy Policy", "Gender Equality", "Immigration",
                                      "Law & Order", "Welfare",
                                      "Local Council", "State Legislature", "National Legislature",
                                      "High School", "University Degree", "PhD", "Same Position",
                                      "More Leftwing", "More Rightwing",
                                      "Man", "Woman"
                       )))


ggData$stat_label <- NA
ggData$stat_label[ggData$statistic == "mm"] <- "MM"

ggData$hline <- NA
ggData$hline[ggData$statistic == "mm"] <- 0.5


ggData$feature2 <- NA
ggData$feature2[ggData$feature == "Conjoint.Age"] = "Age"
ggData$feature2[ggData$feature == "Conjoint.Gender"] = "Gender"
ggData$feature2[ggData$feature == "Conjoint.Experience"] = "Experience"
ggData$feature2[ggData$feature == "Conjoint.MIP"] = "Issue"
ggData$feature2[ggData$feature == "Conjoint.Education"] = "Education"
ggData$feature2[ggData$feature == "Conjoint.Ideology"] = "Ideology"


ggData$feature2 <- as.factor(ggData$feature2)
ggData$feature2 <- (factor(ggData$feature2, levels = c("Gender", "Age", "Education", "Experience", "Ideology","Issue")))

ggData[is.na(ggData$lower),"lower"] <- 0
ggData[is.na(ggData$upper),"upper"] <- 0


dodge <- position_dodge(width=-0.5)
p = ggplot(ggData[ ggData$feature  %in% c("Conjoint.Gender"),], aes(group=Gender ))
p = p + geom_pointrange(aes(x = as.factor(level), y = estimate, ymin = lower, ymax = upper, shape=Gender), position=dodge)
p = p + geom_hline(aes(yintercept = hline), linetype = 2)
p = p + facet_grid(Share ~ "Aspirant Gender", scales = "free_y") + xlab("") + ylab("Marginal Means")
p = p + scale_shape_discrete(labels = c("Man", "Woman")) 
p = p +  labs(shape = "Respondent\nGender") 
p = p + coord_flip() + theme(axis.text = element_text(size = rel(0.8)),
                             axis.ticks = element_line(colour = "black"),
                             legend.key = element_rect(fill = "white"),
                             plot.margin = unit(c(0, 0, 0, 0), "cm"),
                             panel.background = element_rect(fill = "white", colour = NA),
                             panel.border = element_rect(fill = NA, colour = "grey50"),
                             panel.grid.major = element_line(colour = "grey90", size = 0.2),
                             panel.grid.minor = element_line(colour = "grey98", size = 0.5),
                             strip.background = element_rect(fill = "white", colour = "grey50"),
                             strip.text.x = element_text(size = 10, colour = "black", face = "bold"),
                             strip.text.y = element_text(size = 6, colour = "black", face = "bold"))   
p


### FIGURE 17


# No Quota Sample 
dataNoQuota$Share10 <- ifelse(dataNoQuota$Conjoint.Share == "10 Prozent Frauen, 90 Prozent MÃ¤nner", 1,0)
dataNoQuota$Share20 <- ifelse(dataNoQuota$Conjoint.Share == "20 Prozent Frauen, 80 Prozent MÃ¤nner", 1,0)
dataNoQuota$Share30 <- ifelse(dataNoQuota$Conjoint.Share == "30 Prozent Frauen,  70 Prozent MÃ¤nner", 1,0)
dataNoQuota$Share40 <- ifelse(dataNoQuota$Conjoint.Share == "40 Prozent Frauen, 60 Prozent MÃ¤nner", 1,0)
dataNoQuota$Share50 <- ifelse(dataNoQuota$Conjoint.Share == "50 Prozent Frauen, 50 Prozent MÃ¤nner", 1,0)

mm.10M <- mm(dataNoQuota[dataNoQuota$Share10 == 1 & dataNoQuota$Gender == "Man",], f1, id = ~ID,  alpha = 0.05)
mm.10W <- mm(dataNoQuota[dataNoQuota$Share10 == 1 & dataNoQuota$Gender == "Woman",], f1, id = ~ID,  alpha = 0.05)

mm.20M <- mm(dataNoQuota[dataNoQuota$Share20 == 1 & dataNoQuota$Gender == "Man",], f1, id = ~ID,  alpha = 0.05)
mm.20W <- mm(dataNoQuota[dataNoQuota$Share20 == 1 & dataNoQuota$Gender == "Woman",], f1, id = ~ID,  alpha = 0.05)

mm.30M <- mm(dataNoQuota[dataNoQuota$Share30 == 1 & dataNoQuota$Gender == "Man",], f1, id = ~ID,  alpha = 0.05)
mm.30W <- mm(dataNoQuota[dataNoQuota$Share30 == 1 & dataNoQuota$Gender == "Woman",], f1, id = ~ID,  alpha = 0.05)

mm.40M <- mm(dataNoQuota[dataNoQuota$Share40 == 1 & dataNoQuota$Gender == "Man",], f1, id = ~ID,  alpha = 0.05)
mm.40W <- mm(dataNoQuota[dataNoQuota$Share40 == 1 & dataNoQuota$Gender == "Woman",], f1, id = ~ID,  alpha = 0.05)

mm.50M <- mm(dataNoQuota[dataNoQuota$Share50 == 1 & dataNoQuota$Gender == "Man",], f1, id = ~ID,  alpha = 0.05)
mm.50W <- mm(dataNoQuota[dataNoQuota$Share50 == 1 & dataNoQuota$Gender == "Woman",], f1, id = ~ID,  alpha = 0.05)

ggData <- data.frame(rbind(cbind(fold = "10% Women, 90% Men Men", mm.10M),
                           cbind(fold = "20% Women, 80% Men Men", mm.20M),
                           cbind(fold = "30% Women, 70% Men Men", mm.30M),
                           cbind(fold = "40% Women, 60% Men Men", mm.40M),
                           cbind(fold = "50% Women, 50% Men Men", mm.50M),
                           cbind(fold = "10% Women, 90% Men Women", mm.10W),
                           cbind(fold = "20% Women, 80% Men Women", mm.20W),
                           cbind(fold = "30% Women, 70% Men Women", mm.30W),
                           cbind(fold = "40% Women, 60% Men Women", mm.40W),
                           cbind(fold = "50% Women, 50% Men Women", mm.50W)))


ggData$Gender <- NA
ggData$Gender <- ifelse(ggData$fold == "10% Women, 90% Men Women", "Woman", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "20% Women, 80% Men Women", "Woman", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "30% Women, 70% Men Women", "Woman", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "40% Women, 60% Men Women", "Woman", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "50% Women, 50% Men Women", "Woman", ggData$Gender)

ggData$Gender <- ifelse(ggData$fold == "10% Women, 90% Men Men", "Man", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "20% Women, 80% Men Men", "Man", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "30% Women, 70% Men Men", "Man", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "40% Women, 60% Men Men", "Man", ggData$Gender)
ggData$Gender <- ifelse(ggData$fold == "50% Women, 50% Men Men", "Man", ggData$Gender)

ggData$Share <- NA
ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Women", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Women", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Women", "30% Women, 70% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "40% Women, 60% Men Women", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Women", "50% Women, 50% Men", ggData$Share)

ggData$Share <- ifelse(ggData$fold == "10% Women, 90% Men Men", "10% Women, 90% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "20% Women, 80% Men Men", "20% Women, 80% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "30% Women, 70% Men Men", "30% Women, 70% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "40% Women, 60% Men Men", "40% Women, 60% Men", ggData$Share)
ggData$Share <- ifelse(ggData$fold == "50% Women, 50% Men Men", "50% Women, 50% Men", ggData$Share)




ggData$level <- factor(as.character(ggData$level), 
                       levels = rev(c("Under 30","30-39","40-49", "50-59", "60 and Older",
                                      "Taxation", "Energy Policy", "Gender Equality", "Immigration",
                                      "Law & Order", "Welfare",
                                      "Local Council", "State Legislature", "National Legislature",
                                      "High School", "University Degree", "PhD", "Same Position",
                                      "More Leftwing", "More Rightwing",
                                      "Man", "Woman"
                       )))


ggData$stat_label <- NA
ggData$stat_label[ggData$statistic == "mm"] <- "MM"

ggData$hline <- NA
ggData$hline[ggData$statistic == "mm"] <- 0.5


ggData$feature2 <- NA
ggData$feature2[ggData$feature == "Conjoint.Age"] = "Age"
ggData$feature2[ggData$feature == "Conjoint.Gender"] = "Gender"
ggData$feature2[ggData$feature == "Conjoint.Experience"] = "Experience"
ggData$feature2[ggData$feature == "Conjoint.MIP"] = "Issue"
ggData$feature2[ggData$feature == "Conjoint.Education"] = "Education"
ggData$feature2[ggData$feature == "Conjoint.Ideology"] = "Ideology"


ggData$feature2 <- as.factor(ggData$feature2)
ggData$feature2 <- (factor(ggData$feature2, levels = c("Gender", "Age", "Education", "Experience", "Ideology","Issue")))

ggData[is.na(ggData$lower),"lower"] <- 0
ggData[is.na(ggData$upper),"upper"] <- 0

dodge <- position_dodge(width=-0.5)
p = ggplot(ggData[ ggData$feature  %in% c("Conjoint.Gender"),], aes(group=Gender ))
p = p + geom_pointrange(aes(x = as.factor(level), y = estimate, ymin = lower, ymax = upper, shape=Gender), position=dodge)
p = p + geom_hline(aes(yintercept = hline), linetype = 2)
p = p + facet_grid(Share ~ "Aspirant Gender", scales = "free_y") + xlab("") + ylab("Marginal Means")
p = p + scale_shape_discrete(labels = c("Man", "Woman")) 
p = p +  labs(shape = "Respondent\nGender") 
p = p + coord_flip() + theme(axis.text = element_text(size = rel(0.8)),
                             axis.ticks = element_line(colour = "black"),
                             legend.key = element_rect(fill = "white"),
                             plot.margin = unit(c(0, 0, 0, 0), "cm"),
                             panel.background = element_rect(fill = "white", colour = NA),
                             panel.border = element_rect(fill = NA, colour = "grey50"),
                             panel.grid.major = element_line(colour = "grey90", size = 0.2),
                             panel.grid.minor = element_line(colour = "grey98", size = 0.5),
                             strip.background = element_rect(fill = "white", colour = "grey50"),
                             strip.text.x = element_text(size = 10, colour = "black", face = "bold"),
                             strip.text.y = element_text(size = 6, colour = "black", face = "bold"))   
p





